summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-05-31 12:23:12 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-05-31 12:26:09 +0100
commit446d33c39fdabff117b1228e087d037b048fd1f2 (patch)
treef9e95c6dd4acb0d56d339c2d6528dd34c4e9a5f0 /vcl
parentb660074d50acf7befed44c5ed770188b8f3077ec (diff)
gtk3: crash on reusing a popup menu that has a sub menu
Typically popup menus are created froms scratch each time, which is why this wasn't a common problem. To reproduce, under gtk3, set a template as default in the template manager, reset it using dropdown, now set another template as default, and reopen the menu.. it crashes Change-Id: I6107fbd921ada71ef7d676031651deb4b1b2d2fb
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/unx/gtk/gtksalmenu.hxx2
-rw-r--r--vcl/unx/gtk/gtksalmenu.cxx14
2 files changed, 16 insertions, 0 deletions
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 31622fa11cbc..ad3e1d9ad840 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -112,6 +112,8 @@ public:
virtual void Update() override; // Update this menu only.
// Update full menu hierarchy from this menu.
void UpdateFull () { ActivateAllSubmenus(mpVCLMenu); Update(); }
+ // Clear ActionGroup and MenuModel from full menu hierarchy
+ void ClearActionGroupAndMenuModel();
GtkSalMenu* GetTopLevel();
void SetNeedsUpdate();
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index 6a8d52ac4584..414b6b0ed795 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -400,6 +400,7 @@ bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow* pWin, const Rectangle& rRec
gtk_widget_destroy(pWidget);
g_object_unref(mpActionGroup);
+ ClearActionGroupAndMenuModel();
return true;
#else
@@ -1003,6 +1004,19 @@ void GtkSalMenu::ActivateAllSubmenus(Menu* pMenuBar)
}
}
+void GtkSalMenu::ClearActionGroupAndMenuModel()
+{
+ SetMenuModel(nullptr);
+ mpActionGroup = nullptr;
+ for (GtkSalMenuItem* pSalItem : maItems)
+ {
+ if ( pSalItem->mpSubMenu != nullptr )
+ {
+ pSalItem->mpSubMenu->ClearActionGroupAndMenuModel();
+ }
+ }
+}
+
void GtkSalMenu::Activate(const gchar* pCommand)
{
MenuAndId aMenuAndId = decode_command(pCommand);