Skip to content
  • Carlos Garnacho's avatar
    popover: Fix memory management of popovers · 31042fe9
    Carlos Garnacho authored
    Popovers are strange in the sense that they aren't attached to a
    parent directly, they rely on the relative_to widget so the toplevel
    is shared, and when they have a parent, it is the toplevel itself,
    not relative_to. This also means that there are conditions where the
    popover loses it's parent, so they must survive unparenting.
    
    The previous code would be floating the last reference as soon as the
    parent is gone, but it was non-obvious who'd own that reference. So
    fix this situation by granting the ownership of popovers to their
    relative_to widget, an extra reference may be held by the toplevel
    when the popover has a parent, but the popover object will be
    guaranteed to be alive as long as the parent lives.
    
    This way, memory management of popovers is as hidden from the user
    as regular widgets within containers are, users are free to call
    gtk_widget_destroy() on a popover, but it'd eventually become
    destructed when relative_to is.
    31042fe9