aboutsummaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2014-02-23 22:19:48 +0100
committerJavier <dev.git@javispedro.com>2014-02-23 22:19:48 +0100
commit6d0f287cb098a202ad55e198c4737486b731254f (patch)
tree28b1abd66af3a4aeba66b2af44bdbd5be8f89ca1 /module
parent7fddcc13c71ee90384ef0e452e9cc1ebe65d190f (diff)
downloadtopmenu-qt-6d0f287cb098a202ad55e198c4737486b731254f.tar.gz
topmenu-qt-6d0f287cb098a202ad55e198c4737486b731254f.zip
prevent actions being added twice
Diffstat (limited to 'module')
-rw-r--r--module/menuproxy.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/module/menuproxy.cc b/module/menuproxy.cc
index a59a576..81ba1d7 100644
--- a/module/menuproxy.cc
+++ b/module/menuproxy.cc
@@ -82,7 +82,12 @@ GtkMenuItem * MenuProxy::addAction(QAction* action, QAction* before, QMenu* pare
g_parent = m_target;
}
- GtkMenuItem *item;
+ GtkMenuItem *item = getItemForAction(action);
+ if (item) {
+ // Action is already on this proxy.
+ return item;
+ }
+
if (action->isSeparator()) {
item = GTK_MENU_ITEM(gtk_separator_menu_item_new());
} else if (action->isCheckable()) {
@@ -163,6 +168,7 @@ void MenuProxy::removeAction(QAction *action)
GtkMenuItem *item = m_items.value(action);
if (!item) {
+ // Action is not on this proxy
return;
}