Re: [[gtkmm] Destroying menu]



Murray Cumming wrote:

This looks similar to the OptionMenu bug listed here:
http://www.gtkmm.org/bugs.shtml

Maybe you should add a bug. Segfaults are bugs, not features.

"Andrew E. Makeev" <andrew solvo ru> wrote:
[tools                ]
 | add > |

My menubar class contains following members:

class MainMenu : public Gtk::MenuBar
{
   Gtk::Menu m_MenuTools; // this is
   Gtk::Menu m_MenuAdd;   // right

 public:
   MainMenu ()
   {
    ...
    m_MenuTools.items ().push_back (MenuElem ("Add", m_MenuAdd));
    ...
   }
   ~MainMenu ();
};

class MainMenu : public Gtk::MenuBar
{
   Gtk::Menu m_MenuAdd;    // this is
   Gtk::Menu m_MenuTools;  // wrong

 public:
   MainMenu ()
   {
    ...
    m_MenuTools.items ().push_back (MenuElem ("Add", m_MenuAdd));
    ...
   }
   ~MainMenu ();
};

In second case, m_MenuTools gonna be destroyed first, and it will automatically destroy it's children, so, when MainMenu D-TOR would attempt to destroy m_MenuAdd it will segfault.

Yes, you are right. I see the exactly same problem there, just wonder why people couldn't recognize it :).
Well, if you wish I could add some comments to existing issue.

The soultion would be the attempt to force menu to work like Container widget with "manage" feature. So, if you are using submenu as in-class member, Menu won't attempt to destroy it, and if you are creating submenu with manage(), it should be destroyed automatically.

Just one question: how could you force GtkMenu to do not destroy children?

Some time ago, GtkMenu didn't destroy children, so, we haven't met that segfault. Now, it seems, GTK team fixed that, and caused underwater boulders to raise up.

Regards,
-andrew





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