From 51c8602af0079b3f535436d956d3c5353b5b429f Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 7 Apr 2025 09:51:14 +0200 Subject: [PATCH] ActionManager: Work around crash on shutdown The specific case is that RunControls can be deleted with deleteLater (RunControlPrivate::checkAutoDeleteAndEmitStopped), which posts the deleteLater on the event queue. If that happens "just before" shutdown, the remaining events in the event queue are handled just before the event loop exits, but _after_ aboutToQuit is sent and handled. We ramp down plugins on aboutToQuit though, which means that we first delete all plugins, which deletes ActionManager, and after that stray deleteLater events are handled, ~RunControl > ~DebuggerRunTool > ~DebuggerEngine > ActionManager::unregisterAction. Change-Id: I64f7901a647dc44cc88392312e9548cb46c4c192 Reviewed-by: hjk --- src/plugins/coreplugin/actionmanager/actionmanager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.cpp b/src/plugins/coreplugin/actionmanager/actionmanager.cpp index b6cda842765..3ba89cdbb1b 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager.cpp +++ b/src/plugins/coreplugin/actionmanager/actionmanager.cpp @@ -551,6 +551,7 @@ ActionManager::ActionManager(QObject *parent) ActionManager::~ActionManager() { delete d; + d = nullptr; } /*! @@ -734,6 +735,8 @@ QList ActionManager::commands() */ void ActionManager::unregisterAction(QAction *action, Id id) { + if (!d) // stray call during shutdown + return; Command *cmd = d->m_idCmdMap.value(id, nullptr); if (!cmd) { qWarning() << "unregisterAction: id" << id.name()