forked from qt-creator/qt-creator
QtSupport: Restrict QtVersionManagerImpl lifetime to plugin lifetime
This occasionally triggered crashes on static destruction when hard-killing Qt Creator. Giving QtVersionManagerImpl the plugin as QObject parent effectively re-instates the lifetime behavior from before we moved to delayed initialization. We keep the delayed initialization, at the (acceptable) prize of a somewhat quirky setup. Change-Id: I1b4be284a1b573325ed5cc441778eeb48b94c24b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -83,6 +83,8 @@ void QtSupportPlugin::initialize()
|
||||
addTestCreator(createQtProjectImporterTest);
|
||||
#endif
|
||||
|
||||
setupQtVersionManager(this);
|
||||
|
||||
setupDesktopQtVersion();
|
||||
setupEmbeddedLinuxQtVersion();
|
||||
setupGettingStartedWelcomePage();
|
||||
|
@@ -89,7 +89,8 @@ static PersistentSettingsWriter *m_writer = nullptr;
|
||||
class QtVersionManagerImpl : public QObject
|
||||
{
|
||||
public:
|
||||
QtVersionManagerImpl()
|
||||
QtVersionManagerImpl(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qRegisterMetaType<FilePath>();
|
||||
|
||||
@@ -135,10 +136,18 @@ public:
|
||||
QTimer m_fileWatcherTimer;
|
||||
};
|
||||
|
||||
static QObject *s_guard = nullptr;
|
||||
|
||||
void Internal::setupQtVersionManager(QObject *guard)
|
||||
{
|
||||
s_guard = guard;
|
||||
}
|
||||
|
||||
QtVersionManagerImpl &qtVersionManagerImpl()
|
||||
{
|
||||
static QtVersionManagerImpl theQtVersionManager;
|
||||
return theQtVersionManager;
|
||||
QTC_CHECK(s_guard);
|
||||
static auto theQtVersionManager = new QtVersionManagerImpl(s_guard);
|
||||
return *theQtVersionManager;
|
||||
}
|
||||
|
||||
void QtVersionManagerImpl::triggerQtVersionRestore()
|
||||
|
@@ -70,4 +70,6 @@ private:
|
||||
static int getUniqueId();
|
||||
};
|
||||
|
||||
namespace Internal { void setupQtVersionManager(QObject *guard); }
|
||||
|
||||
} // namespace QtSupport
|
||||
|
Reference in New Issue
Block a user