Bugs: Browse | Submit New | Admin

[#29218] Risk of incorrect deletion of Wx::Menu

Date:
2011-05-21 19:34
Priority:
2
Submitted By:
Alex Fenton (brokentoy)
Assigned To:
Alex Fenton (brokentoy)
Category:
Incorrect behavior
State:
Open
Summary:
Risk of incorrect deletion of Wx::Menu

Detailed description
wxRuby protects MenuBar and its associated Menus from GC by marking them via their associated frame. It is possible
that a partially-created menu might be incorrectly destroyed before it's associated with a Frame, if GC is triggered
during the set-up of the menu and the Menus are not connected by instance variables.

For example

menubar = Wx::MenuBar.new(...)
menubar.append(SomeMenuSubClass.new)
# GC can be triggered here
frame.menubar = menubar

Tricky to fix in GC without being over-conservative and always preserving menus. Workaround is to connect the MenuBar
to the frame early using menubar=

Add A Comment: Notepad

Please login


Followup

Message
Date: 2011-05-23 04:09
Sender: Chauk-Mean Proum

Another workaround would be to disable the garbage collector
during the application startup. Garbage collector disabling/reenabling
could be possibly done by wxRuby.
Date: 2011-05-22 10:30
Sender: Alex Fenton

Potential fix - make wxRuby_markMenuBarBelongingToFrame the markfunc
of MenuBar, but add code in to setWindowDeleted to check if a
frame, with menubar, and unlink the menubar at that point so
it is not later incorrectly marked.

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item