From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sun, 26 Aug 2012 16:35:02 +0000 (+0000)
Subject: Avoid crashes when creating initially hidden MDI child under Unity.
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/45f0926d4196f59ed6906056793df598462e5b55

Avoid crashes when creating initially hidden MDI child under Unity.

Ignore "hide" signals for the menus without associated shown window. Ubuntu
Unity sends them and we crashed because of a recursive assert in the
corresponding signal handler before.

Now the code doesn't crash any more but the menus still don't behave correctly
when the last MDI child is destroyed.

Closes #13593.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72379 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp
index a9e1627ec7..fe3ebb03a3 100644
--- a/src/gtk/menu.cpp
+++ b/src/gtk/menu.cpp
@@ -684,6 +684,13 @@ static void menu_map(GtkWidget*, wxMenu* menu)
 // "hide" from m_menu
 static void menu_hide(GtkWidget*, wxMenu* menu)
 {
+    // When using Ubuntu Unity desktop environment we get "hide" signal even
+    // when the window is not shown yet because Unity hides all the menus to
+    // show them only in the global menu bar. Just ignore this even instead of
+    // crashing in DoCommonMenuCallbackCode().
+    if ( !menu->GetWindow() )
+        return;
+
     wxMenuEvent event(wxEVT_MENU_CLOSE, menu->m_popupShown ? -1 : 0, menu);
     menu->m_popupShown = false;
     DoCommonMenuCallbackCode(menu, event);