Re: Menu Implementation problem



On Wed, 2006-04-26 at 09:51 +0400, Andrew E. Makeev wrote:
> MERT TUGCU wrote:
> 
> > Dear All,
> >
> > I have a program, which has a menu implementation. It works fine 
> > except when I quit, I get several warnings and sometimes segmentation 
> > fault. It seems that the menu objects are not destroyed properly. 
> > Would you please let me know, what I am doing wrong here? Thanks.
> > Here is my menu implementation:
> >
> > //Fill main menu bar
> > menuBar.items().push_back(Gtk::Menu_Helpers::MenuElem("File",fileMenu));
> > menuBar.items().push_back(Gtk::Menu_Helpers::MenuElem("Memory",memoryMenu)); 
> >
> > //File menu:
> > {
> >     Gtk::Menu::MenuList& menulist = fileMenu.items();
> >     menulist.push_back( Gtk::Menu_Helpers::MenuElem("Load", 
> > trainingData_submenu) ); //Add submenu.
> >     menulist.push_back( Gtk::Menu_Helpers::MenuElem("Save Training 
> > Data", \
> >         sigc::mem_fun(*this, &InterfaceWindow::on_menu_saveTree) ) );
> >     menulist.push_back( 
> > Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::QUIT, \
> >         sigc::mem_fun(*this, &InterfaceWindow::on_menu_quit) ) );
> > }
> > //Memory menu:
> > {
> > Gtk::Menu::MenuList& menulist = memoryMenu.items();
> >     menulist.push_back( Gtk::Menu_Helpers::MenuElem("Clear", \
> >         sigc::mem_fun(*this, &InterfaceWindow::on_menu_clear) ) );
> > }
> > //File|Load Submenu:
> > {
> >     Gtk::Menu::MenuList& menulist = trainingData_submenu.items();
> >     menulist.push_back( Gtk::Menu_Helpers::MenuElem("Training Data", 
> > fileMenu_Load_submenu) ); /Add submenu.
> >     menulist.push_back( Gtk::Menu_Helpers::MenuElem("WM Network 
> > Weights",sigc::mem_fun(*this, 
> > InterfaceWindow::on_menu_load_WM_Network) ) );
> > }
> > //File|Load|Training Data Submenu:
> > {
> >     Gtk::Menu::MenuList& menulist = fileMenu_Load_submenu.items();
> >     menulist.push_back( Gtk::Menu_Helpers::MenuElem("All(default)", \
> >     sigc::mem_fun(*this, &InterfaceWindow::on_menu_loadDefault) ) );
> >     menulist.push_back( Gtk::Menu_Helpers::MenuElem("From file", \
> >     sigc::mem_fun(*this, &InterfaceWindow::on_menu_loadFromFile) ) );
> > }
> >
> I've noticed wrong memory management with menu bars (menu packed in some 
> widget) in versions GTKMM-2.2, 2.4.
> So, when you are creating Gtk::MenuBar avoid to use Gtk::manage(). Menu 
> will be deleted as child widget automatically when parent container 
> destroyed regardless "manage" flag. In other case, it will be destroyed 
> twice.

I recommend valgrind to debug memory management problems. And if you
think there's a problem in gtkmm itself, please provide a test case.

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]