Kaydet (Commit) 8e8de0a1 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#122931 crash on closing b&n dialog after gallery menu activated

Change-Id: I3284edc2ed64895642bd12ea479a1aba8023b2ba
Reviewed-on: https://gerrit.libreoffice.org/66873
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst c66027d1
...@@ -1826,6 +1826,15 @@ public: ...@@ -1826,6 +1826,15 @@ public:
g_signal_connect(pMenuItem, "activate", G_CALLBACK(signalActivate), this); g_signal_connect(pMenuItem, "activate", G_CALLBACK(signalActivate), this);
} }
void remove_from_map(GtkMenuItem* pMenuItem)
{
const gchar* pStr = gtk_buildable_get_name(GTK_BUILDABLE(pMenuItem));
OString id(pStr, pStr ? strlen(pStr) : 0);
auto iter = m_aMap.find(id);
g_signal_handlers_disconnect_by_data(iter->second, this);
m_aMap.erase(iter);
}
void disable_item_notify_events() void disable_item_notify_events()
{ {
for (auto& a : m_aMap) for (auto& a : m_aMap)
...@@ -4200,6 +4209,7 @@ public: ...@@ -4200,6 +4209,7 @@ public:
class GtkInstanceMenu : public MenuHelper, public virtual weld::Menu class GtkInstanceMenu : public MenuHelper, public virtual weld::Menu
{ {
protected: protected:
std::vector<GtkMenuItem*> m_aExtraItems;
OString m_sActivated; OString m_sActivated;
GtkInstanceMenuButton* m_pTopLevelMenuButton; GtkInstanceMenuButton* m_pTopLevelMenuButton;
...@@ -4358,12 +4368,22 @@ public: ...@@ -4358,12 +4368,22 @@ public:
gtk_menu_shell_append(GTK_MENU_SHELL(m_pMenu), pItem); gtk_menu_shell_append(GTK_MENU_SHELL(m_pMenu), pItem);
gtk_widget_show(pItem); gtk_widget_show(pItem);
GtkMenuItem* pMenuItem = GTK_MENU_ITEM(pItem); GtkMenuItem* pMenuItem = GTK_MENU_ITEM(pItem);
m_aExtraItems.push_back(pMenuItem);
add_to_map(pMenuItem); add_to_map(pMenuItem);
if (m_pTopLevelMenuButton) if (m_pTopLevelMenuButton)
m_pTopLevelMenuButton->add_to_map(pMenuItem); m_pTopLevelMenuButton->add_to_map(pMenuItem);
if (pos != -1) if (pos != -1)
gtk_menu_reorder_child(m_pMenu, pItem, pos); gtk_menu_reorder_child(m_pMenu, pItem, pos);
} }
virtual ~GtkInstanceMenu() override
{
if (m_pTopLevelMenuButton)
{
for (auto a : m_aExtraItems)
m_pTopLevelMenuButton->remove_from_map(a);
}
}
}; };
class GtkInstanceRadioButton : public GtkInstanceToggleButton, public virtual weld::RadioButton class GtkInstanceRadioButton : public GtkInstanceToggleButton, public virtual weld::RadioButton
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment