#15237 closed defect (fixed)

Problem with reparenting a TLW as child window

Reported by: Chuddah Owned by:
Priority: low Milestone:
Component: wxGTK Version: stable-latest
Keywords: reparent toplevel Cc:
Blocked By: Blocking:
Patch: yes

Description

Reparenting a widget in GTK involved updating the child list of the parent and updating the parent of the child.
In the case of TopLevelWindows; the parent is always NULL.

Reparenting a top level window to be the child of a widget fails to update the parent item of the top level, although, updates the child list of the parent to include the top level window (See https://bugzilla.gnome.org/show_bug.cgi?id=701296 )

This causes problems later when assertions are made to verify the parent item of a widget is indeed a child of its parent.

Ive submitted the fix for this to GTK although there is a quick workaround that can be put into wxWidgets.

Damien,

Attachments (2)

reparent_top_level.py download (353 bytes) - added by Chuddah 19 months ago.
wxPython bug reproduction
wxWidgets_fixed_toplevel_children_workaround.patch download (689 bytes) - added by Chuddah 19 months ago.
patch file

Download all attachments as: .zip

Change History (6)

Changed 19 months ago by Chuddah

wxPython bug reproduction

Changed 19 months ago by Chuddah

patch file

comment:1 Changed 19 months ago by vadz

  • Milestone 2.9.5 deleted
  • Priority changed from high to low
  • Summary changed from gtk widgets have children who deny they have a parent to Problem with reparenting a TLW as child window

Does it really make any sense to reparent a TLW as a child? This doesn't risk to work under MSW anyhow...

I'd rather add an assert verifying that we don't have a TLW here instead of trying to support something that is sure to only result in more grief.

comment:2 Changed 19 months ago by Chuddah

Does it really make any sense to reparent a TLW as a child?

Only as much sense as it does to construct a TLW with a parent

TLW may be created with a parent on construction, so it makes sense to allow a TLW to be re-parented to another window from the view of wxWidgets.
The 2 code snippets below should leave the window manager/wxWidgets in the same state...

parent_frame = wx.Frame(None)
child_frame = wx.Frame(parent=parent_frame)

parent_frame = wx.Frame(None)
child_frame = wx.Frame(None)
child_frame.Reparent(parent_frame)

So now, when parent_frame is destroyed child_frame is also destroyed.

This already works fine under MSW without any modifications to wxWidgets.
The changes in the included patch file only effect GTK and make wxWidgets a little more consistent across OSs.

Damien,

comment:3 Changed 19 months ago by vadz

OK, if it already works elsewhere, I agree that it should work in wxGTK too.

I'll apply the patch soon, thanks!

comment:4 Changed 19 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [74155]) Avoid problems when reparenting a TLW under a child in wxGTK.

Don't use a TLW with gtk_fixed_put().

Closes #15237.

Note: See TracTickets for help on using tickets.