summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <tsdgeos@terra.es>2012-07-01 09:06:44 (GMT)
committerAlbert Astals Cid <tsdgeos@terra.es>2012-07-17 18:18:51 (GMT)
commit776098aae397b499a95d6855ef16f67eb8546598 (patch)
treec000c293dd57fa8f72ba3ca8b257d0b17ef931c8
parentbbb0c55eb463389f25d04c9f4167b807a93c83ce (diff)
Do not leave dangling pointers in KToolbar when xml clients die
Acked by dfaure REVIEW: 105399 BUGS: 296622 FIXED-IN: 4.8.5
-rw-r--r--kdeui/widgets/ktoolbar.cpp5
-rw-r--r--kdeui/widgets/ktoolbar.h6
-rw-r--r--kdeui/xmlgui/kxmlguifactory_p.cpp5
3 files changed, 16 insertions, 0 deletions
diff --git a/kdeui/widgets/ktoolbar.cpp b/kdeui/widgets/ktoolbar.cpp
index c6bd200..120c244 100644
--- a/kdeui/widgets/ktoolbar.cpp
+++ b/kdeui/widgets/ktoolbar.cpp
@@ -864,6 +864,11 @@ void KToolBar::addXMLGUIClient( KXMLGUIClient *client )
d->xmlguiClients << client;
}
+void KToolBar::removeXMLGUIClient( KXMLGUIClient *client )
+{
+ d->xmlguiClients.remove(client);
+}
+
void KToolBar::contextMenuEvent(QContextMenuEvent* event)
{
#ifndef KDE_NO_DEPRECATED
diff --git a/kdeui/widgets/ktoolbar.h b/kdeui/widgets/ktoolbar.h
index c78263f..f83417b 100644
--- a/kdeui/widgets/ktoolbar.h
+++ b/kdeui/widgets/ktoolbar.h
@@ -176,6 +176,12 @@ public:
void addXMLGUIClient( KXMLGUIClient *client );
/**
+ * Removes an XML gui client that uses this toolbar
+ * @since 4.8.5
+ */
+ void removeXMLGUIClient( KXMLGUIClient *client );
+
+ /**
* Load state from an XML @param element, called by KXMLGUIBuilder.
*/
void loadState( const QDomElement &element );
diff --git a/kdeui/xmlgui/kxmlguifactory_p.cpp b/kdeui/xmlgui/kxmlguifactory_p.cpp
index 083ddf5..31a528c 100644
--- a/kdeui/xmlgui/kxmlguifactory_p.cpp
+++ b/kdeui/xmlgui/kxmlguifactory_p.cpp
@@ -438,6 +438,11 @@ void ContainerNode::unplugClient( ContainerClient *client )
for (; custIt != custEnd; ++custIt )
builder->removeCustomElement( container, *custIt );
+ KToolBar *bar = qobject_cast<KToolBar*>(container);
+ if (bar) {
+ bar->removeXMLGUIClient(client->client);
+ }
+
client->actions.unplug( container );
// now adjust all merging indices