[wxruby-users] wxruby 1.9.9 menu - strange corruption
Alex Fenton
alex at pressure.to
Mon Jan 5 06:31:49 EST 2009
Hi Ridge
Ridge Mcghee wrote:
> Good suggestion (1) and that is actually what I did to move forward.
>
Glad that worked, and also thanks for spotting this and bringing it up.
> However, I consider it a work-around. I welcome your explanations
> because I want to understand.
>
> Here's my view:
> As a developer, I don't want just the "native" superclass to work
> properly with the GC. I want my sub-classes to work properly, too.
>
>
I understand that, and indeed most classes where you'd want that should
already do that. First up I'll say that having seen your example, I
agree that MenuItem should work correctly - ie that a custom subclass
should be maintained.
As you'll have realised wxRuby is a big library with 200+ classes, and
for each of them we have to select a memory management strategy. It needs
1) to be safe - ie it won't crash under any various circumstance it's used
2) to be efficient - it won't leak memory, or unnecessarily slow the
library (for example, GNOME2 can suffer pauses due to GC, which limits
its usefulessness for real-time drawing apps)
3) to work well with Ruby's dynamic object model
4) to work OK with wxWidgets C++ object ownership and memory management
The current implementation does 1, 2 and 4 but not 3 - I simply hadn't
foreseen the use-case demonstrated by your sample.
> I appreciate your offer to "have a look" and I'd be interested to
> know whatever you find out.
Over the weekend I made a change to my working tree. The result of this
patch would be that MenuItems, once added to a Menu, would have the
original object preserved. This would resolve your issue.
Historically Menus and MenuItems have been among the most problematic
for GC, so it's moderately high-risk. I'm going to test it further for a
few days, then commit, then we can give it some further working out on
all platforms. Since you're on Windows I'm guessing you don't have the
compiler infrastructure, in which case it'll be available for the next
2.0 release.
best
alex
More information about the wxruby-users
mailing list