From 176b31198e0c3718b5ca4de864744b5d3c235af7 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Wed, 21 Oct 2015 14:05:49 +0200 Subject: [PATCH] Plugins: Set plugin as parent for all created actions This fixes crash on Windows when unloading plugin and then showing a menu where the plugin action was. There is still crash on exit in that case. --- src/plugins/TabManager/tabmanagerplugin.cpp | 1 - src/plugins/TabManager/tabmanagerwidgetcontroller.cpp | 2 +- src/plugins/TestPlugin/testplugin_sidebar.cpp | 5 ++++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/TabManager/tabmanagerplugin.cpp b/src/plugins/TabManager/tabmanagerplugin.cpp index f8e363687..f6565f94d 100644 --- a/src/plugins/TabManager/tabmanagerplugin.cpp +++ b/src/plugins/TabManager/tabmanagerplugin.cpp @@ -116,7 +116,6 @@ void TabManagerPlugin::populateExtensionsMenu(QMenu* menu) { if (viewType() == ShowAsWindow) { QAction* showAction = m_controller->createMenuAction(); - showAction->setParent(menu); showAction->setCheckable(false); connect(showAction, SIGNAL(triggered()), m_controller, SLOT(raiseTabManager())); menu->addAction(showAction); diff --git a/src/plugins/TabManager/tabmanagerwidgetcontroller.cpp b/src/plugins/TabManager/tabmanagerwidgetcontroller.cpp index 994eaff5b..a27346256 100644 --- a/src/plugins/TabManager/tabmanagerwidgetcontroller.cpp +++ b/src/plugins/TabManager/tabmanagerwidgetcontroller.cpp @@ -48,7 +48,7 @@ QString TabManagerWidgetController::title() const QAction* TabManagerWidgetController::createMenuAction() { - QAction* act = new QAction(tr("Tab Manager"), 0); + QAction* act = new QAction(tr("Tab Manager"), this); act->setCheckable(true); act->setIcon(QIcon(":tabmanager/data/tabmanager.png")); act->setShortcut(QKeySequence("Ctrl+Shift+M")); diff --git a/src/plugins/TestPlugin/testplugin_sidebar.cpp b/src/plugins/TestPlugin/testplugin_sidebar.cpp index d9896f597..1bc224360 100644 --- a/src/plugins/TestPlugin/testplugin_sidebar.cpp +++ b/src/plugins/TestPlugin/testplugin_sidebar.cpp @@ -34,7 +34,10 @@ QString TestPlugin_Sidebar::title() const QAction* TestPlugin_Sidebar::createMenuAction() { - QAction* act = new QAction(tr("Testing Sidebar"), 0); + // The action must be parented to some object from plugin, otherwise + // there may be a crash when unloading the plugin. + + QAction* act = new QAction(tr("Testing Sidebar"), this); act->setCheckable(true); return act;