Ios: Fix a possible crash on shutdown

Since IosDeviceManager is a static object, it's destructed
after the shutdown phase has passed. But since the destructor
of IosDeviceManager may be deleting the running task trees
containing the running processes, it may crash since the
ProcessReaper is gone at this stage.

To fix it, create IosDeviceManager on heap and pass a
shutdown guard as a parent, so that it's deleted before
the ProcessReaper is gone.

Fixes: QTCREATORBUG-31484
Change-Id: Ieaac16331304cffbe3f50291d7d914aebfa0b2e3
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Jarek Kobus
2024-09-18 14:20:28 +02:00
parent 773b45eebc
commit 0bdfe776ec

View File

@@ -13,6 +13,8 @@
#include <coreplugin/helpmanager.h> #include <coreplugin/helpmanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <extensionsystem/shutdownguard.h>
#include <projectexplorer/devicesupport/devicemanager.h> #include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/devicesupport/idevicefactory.h> #include <projectexplorer/devicesupport/idevicefactory.h>
#include <projectexplorer/devicesupport/idevicewidget.h> #include <projectexplorer/devicesupport/idevicewidget.h>
@@ -589,8 +591,8 @@ void IosDeviceManager::updateUserModeDevices()
IosDeviceManager *IosDeviceManager::instance() IosDeviceManager *IosDeviceManager::instance()
{ {
static IosDeviceManager obj; static IosDeviceManager *theInstance = new IosDeviceManager(ExtensionSystem::shutdownGuard());
return &obj; return theInstance;
} }
void IosDeviceManager::updateAvailableDevices(const QStringList &devices) void IosDeviceManager::updateAvailableDevices(const QStringList &devices)