forked from qt-creator/qt-creator
DeviceManager: Fix lifecycle
This prevents a crash when the DeviceManager tries to bring up a UI during its destruction. This happens in the same situation as described in QTCREATORBUG-11712, which actually describes the same problem in BlackBerryConfigurationManager. Change-Id: I06f134ffa282a281c81fd022c5a2f52fb5dddb56 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/persistentsettings.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -81,11 +82,11 @@ DeviceManager *DeviceManagerPrivate::clonedInstance = 0;
|
||||
|
||||
using namespace Internal;
|
||||
|
||||
DeviceManager *DeviceManager::m_instance = 0;
|
||||
|
||||
DeviceManager *DeviceManager::instance()
|
||||
{
|
||||
static DeviceManager instance;
|
||||
return &instance;
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
int DeviceManager::deviceCount() const
|
||||
@@ -337,14 +338,19 @@ const IDeviceFactory *DeviceManager::restoreFactory(const QVariantMap &map)
|
||||
|
||||
DeviceManager::DeviceManager(bool isInstance) : d(new DeviceManagerPrivate)
|
||||
{
|
||||
if (isInstance)
|
||||
if (isInstance) {
|
||||
QTC_ASSERT(!m_instance, return);
|
||||
m_instance = this;
|
||||
connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), SLOT(save()));
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::~DeviceManager()
|
||||
{
|
||||
if (d->clonedInstance != this)
|
||||
delete d->writer;
|
||||
if (m_instance == this)
|
||||
m_instance = 0;
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
@@ -110,6 +110,8 @@ private:
|
||||
|
||||
Internal::DeviceManagerPrivate * const d;
|
||||
|
||||
static DeviceManager *m_instance;
|
||||
|
||||
friend class Internal::DeviceManagerPrivate;
|
||||
friend class ProjectExplorerPlugin;
|
||||
};
|
||||
|
@@ -330,6 +330,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
return false;
|
||||
addObject(this);
|
||||
|
||||
addAutoReleasedObject(new DeviceManager);
|
||||
|
||||
// Add ToolChainFactories:
|
||||
#ifdef Q_OS_WIN
|
||||
addAutoReleasedObject(new WinDebugInterface);
|
||||
|
Reference in New Issue
Block a user