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 <hjk@qt.io>
This commit is contained in:
Eike Ziller
2025-04-07 09:51:14 +02:00
parent 19a13932a4
commit 51c8602af0

View File

@@ -551,6 +551,7 @@ ActionManager::ActionManager(QObject *parent)
ActionManager::~ActionManager() ActionManager::~ActionManager()
{ {
delete d; delete d;
d = nullptr;
} }
/*! /*!
@@ -734,6 +735,8 @@ QList<Command *> ActionManager::commands()
*/ */
void ActionManager::unregisterAction(QAction *action, Id id) void ActionManager::unregisterAction(QAction *action, Id id)
{ {
if (!d) // stray call during shutdown
return;
Command *cmd = d->m_idCmdMap.value(id, nullptr); Command *cmd = d->m_idCmdMap.value(id, nullptr);
if (!cmd) { if (!cmd) {
qWarning() << "unregisterAction: id" << id.name() qWarning() << "unregisterAction: id" << id.name()