[fxruby-users] [Foxgui-users] Segmentation fault on exit

Melton, Ryan rmelton at ball.com
Thu Jun 12 14:42:17 EDT 2008

How would you delete the Menu Pane using FXRuby?

-----Original Message-----
From: foxgui-users-bounces at lists.sourceforge.net
[mailto:foxgui-users-bounces at lists.sourceforge.net] On Behalf Of Jeroen
van der Zijp
Sent: Thursday, June 12, 2008 10:22 AM
To: Dr Gavin Tabor
Cc: FOX Users
Subject: Re: [Foxgui-users] Segmentation fault on exit

On Thursday 12 June 2008, you wrote:
> Hi there. I am probably doing something really stupid here, but I am
> having difficulty getting my Fox application to exit cleanly. I have
> written it as a new class "viewer"; my top level code looks like this;
>   // Make application
>   FXApp application("GLTest","FoxTest");
>   // Open the display
>   application.init(argc,argv);
>   // Make window
>   new viewer(&application,meshDescription, runTime);
>   // Create the application's windows
>   application.create();
>   // Run the application
>   return application.run();
> Viewer is a gl window with a menubar across the top; one of the
> in the pull-down menu is an exit button, implemented thus;
>   filemenuQuit_ = new FXMenuCommand
>   (
>       filemenu_,
>       "&Quit\tCtl-Q",
>       NULL,
>       getApp(),
>       FXApp::ID_QUIT
>   );
> which I believe is the standard way of exiting a Fox application
> viewer also contains a destructor function ~viewer which cleans up all
> the memory allocated to the viewer object. It ends with a statement
> Info << "Out here\n"; to identify where I have got to. When I run the
> code and try to exit, I get "Out here" followed by a segmentation
> So I believe it is getting to the end of the destructor function with
> problem, but beyond that something is going wrong. Can anyone help me
> identify what the problem is, please? AFAICT, my exit button passes
> message FXApp::ID_QUIT to the application; what happens after that??

The most likely cause is that the menu pane is not being deleted
explicitly, and then continues to exist after the main window that
owns it has already been deleted.  

When an FXMenuPane is deleted, all the menu commands in it will try to
remove their accelerators from the main window's accelerator table.
This will not work, since the main window is already gone.

Solution: in your main window's destructor, delete all menu panes owned
by that main window.  This way, the destructors inside the FXMenuPane
and its children will be running BEFORE the main window itself is

Hope this helps,

		- Jeroen

Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
Foxgui-users mailing list
Foxgui-users at lists.sourceforge.net

This message and any enclosures are intended only for the addressee.  Please  
notify the sender by email if you are not the intended recipient.  If you are  
not the intended recipient, you may not use, copy, disclose, or distribute this  
message or its contents or enclosures to any other person and any such actions  
may be unlawful.  Ball reserves the right to monitor and review all messages  
and enclosures sent to or from this email address.

More information about the fxruby-users mailing list