forked from qt-creator/qt-creator
Centralize a PluginManager::isShuttingDown() status
Instead of keeping track of this in plugins individually. Change-Id: Ia2650f0f647d4a63d2010cef688aa56f6020c338 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1034,6 +1034,7 @@ void PluginManagerPrivate::readSettings()
|
|||||||
*/
|
*/
|
||||||
void PluginManagerPrivate::stopAll()
|
void PluginManagerPrivate::stopAll()
|
||||||
{
|
{
|
||||||
|
m_isShuttingDown = true;
|
||||||
if (delayedInitializeTimer && delayedInitializeTimer->isActive()) {
|
if (delayedInitializeTimer && delayedInitializeTimer->isActive()) {
|
||||||
delayedInitializeTimer->stop();
|
delayedInitializeTimer->stop();
|
||||||
delete delayedInitializeTimer;
|
delete delayedInitializeTimer;
|
||||||
@@ -1839,6 +1840,11 @@ bool PluginManager::isInitializationDone()
|
|||||||
return d->m_isInitializationDone;
|
return d->m_isInitializationDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PluginManager::isShuttingDown()
|
||||||
|
{
|
||||||
|
return d->m_isShuttingDown;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Retrieves one object with \a name from the object pool.
|
Retrieves one object with \a name from the object pool.
|
||||||
\sa addObject()
|
\sa addObject()
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ public:
|
|||||||
static QString platformName();
|
static QString platformName();
|
||||||
|
|
||||||
static bool isInitializationDone();
|
static bool isInitializationDone();
|
||||||
|
static bool isShuttingDown();
|
||||||
|
|
||||||
static void remoteArguments(const QString &serializedArguments, QObject *socket);
|
static void remoteArguments(const QString &serializedArguments, QObject *socket);
|
||||||
static void shutdown();
|
static void shutdown();
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ public:
|
|||||||
|
|
||||||
bool m_isInitializationDone = false;
|
bool m_isInitializationDone = false;
|
||||||
bool enableCrashCheck = true;
|
bool enableCrashCheck = true;
|
||||||
|
bool m_isShuttingDown = false;
|
||||||
|
|
||||||
QHash<QString, std::function<bool()>> m_scenarios;
|
QHash<QString, std::function<bool()>> m_scenarios;
|
||||||
QString m_requestedScenario;
|
QString m_requestedScenario;
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
#include "../settingsdatabase.h"
|
#include "../settingsdatabase.h"
|
||||||
#include "../statusbarmanager.h"
|
#include "../statusbarmanager.h"
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/async.h>
|
#include <utils/async.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -147,7 +149,6 @@ bool Locator::delayedInitialize()
|
|||||||
|
|
||||||
void Locator::aboutToShutdown()
|
void Locator::aboutToShutdown()
|
||||||
{
|
{
|
||||||
m_shuttingDown = true;
|
|
||||||
m_refreshTimer.stop();
|
m_refreshTimer.stop();
|
||||||
m_taskTree.reset();
|
m_taskTree.reset();
|
||||||
}
|
}
|
||||||
@@ -373,7 +374,7 @@ void Locator::setUseCenteredPopupForShortcut(bool center)
|
|||||||
|
|
||||||
void Locator::refresh(const QList<ILocatorFilter *> &filters)
|
void Locator::refresh(const QList<ILocatorFilter *> &filters)
|
||||||
{
|
{
|
||||||
if (m_shuttingDown)
|
if (ExtensionSystem::PluginManager::isShuttingDown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_taskTree.reset(); // Superfluous, just for clarity. The next reset() below is enough.
|
m_taskTree.reset(); // Superfluous, just for clarity. The next reset() below is enough.
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ private:
|
|||||||
bool useCenteredPopup = false;
|
bool useCenteredPopup = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool m_shuttingDown = false;
|
|
||||||
bool m_settingsInitialized = false;
|
bool m_settingsInitialized = false;
|
||||||
Settings m_settings;
|
Settings m_settings;
|
||||||
QList<ILocatorFilter *> m_filters;
|
QList<ILocatorFilter *> m_filters;
|
||||||
|
|||||||
@@ -686,7 +686,6 @@ public:
|
|||||||
|
|
||||||
EngineManager m_engineManager;
|
EngineManager m_engineManager;
|
||||||
QTimer m_shutdownTimer;
|
QTimer m_shutdownTimer;
|
||||||
bool m_shuttingDown = false;
|
|
||||||
|
|
||||||
Console m_console; // ensure Debugger Console is created before settings are taken into account
|
Console m_console; // ensure Debugger Console is created before settings are taken into account
|
||||||
DebuggerSettings m_debuggerSettings;
|
DebuggerSettings m_debuggerSettings;
|
||||||
@@ -1392,7 +1391,7 @@ static QVariant configValue(const QString &name)
|
|||||||
|
|
||||||
void DebuggerPluginPrivate::updatePresetState()
|
void DebuggerPluginPrivate::updatePresetState()
|
||||||
{
|
{
|
||||||
if (m_shuttingDown)
|
if (PluginManager::isShuttingDown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Project *startupProject = ProjectManager::startupProject();
|
Project *startupProject = ProjectManager::startupProject();
|
||||||
@@ -1996,8 +1995,6 @@ void DebuggerPluginPrivate::dumpLog()
|
|||||||
|
|
||||||
void DebuggerPluginPrivate::aboutToShutdown()
|
void DebuggerPluginPrivate::aboutToShutdown()
|
||||||
{
|
{
|
||||||
m_shuttingDown = true;
|
|
||||||
|
|
||||||
disconnect(ProjectManager::instance(), &ProjectManager::startupProjectChanged, this, nullptr);
|
disconnect(ProjectManager::instance(), &ProjectManager::startupProjectChanged, this, nullptr);
|
||||||
|
|
||||||
m_shutdownTimer.setInterval(0);
|
m_shutdownTimer.setInterval(0);
|
||||||
@@ -2081,7 +2078,7 @@ QWidget *addSearch(BaseTreeView *treeView)
|
|||||||
|
|
||||||
void openTextEditor(const QString &titlePattern0, const QString &contents)
|
void openTextEditor(const QString &titlePattern0, const QString &contents)
|
||||||
{
|
{
|
||||||
if (dd->m_shuttingDown)
|
if (PluginManager::isShuttingDown())
|
||||||
return;
|
return;
|
||||||
QString titlePattern = titlePattern0;
|
QString titlePattern = titlePattern0;
|
||||||
IEditor *editor = EditorManager::openEditorWithContents(
|
IEditor *editor = EditorManager::openEditorWithContents(
|
||||||
|
|||||||
@@ -135,11 +135,6 @@ void EmacsKeysPlugin::extensionsInitialized()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag EmacsKeysPlugin::aboutToShutdown()
|
|
||||||
{
|
|
||||||
return SynchronousShutdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmacsKeysPlugin::editorAboutToClose(IEditor *editor)
|
void EmacsKeysPlugin::editorAboutToClose(IEditor *editor)
|
||||||
{
|
{
|
||||||
auto w = qobject_cast<QPlainTextEdit*>(editor->widget());
|
auto w = qobject_cast<QPlainTextEdit*>(editor->widget());
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ public:
|
|||||||
|
|
||||||
void initialize() override;
|
void initialize() override;
|
||||||
void extensionsInitialized() override;
|
void extensionsInitialized() override;
|
||||||
ShutdownFlag aboutToShutdown() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void editorAboutToClose(Core::IEditor *editor);
|
void editorAboutToClose(Core::IEditor *editor);
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <languageserverprotocol/completion.h>
|
#include <languageserverprotocol/completion.h>
|
||||||
#include <languageserverprotocol/diagnostics.h>
|
#include <languageserverprotocol/diagnostics.h>
|
||||||
#include <languageserverprotocol/initializemessages.h>
|
#include <languageserverprotocol/initializemessages.h>
|
||||||
@@ -194,7 +196,7 @@ public:
|
|||||||
// temporary container needed since m_resetAssistProvider is changed in resetAssistProviders
|
// temporary container needed since m_resetAssistProvider is changed in resetAssistProviders
|
||||||
for (TextDocument *document : m_resetAssistProvider.keys())
|
for (TextDocument *document : m_resetAssistProvider.keys())
|
||||||
resetAssistProviders(document);
|
resetAssistProviders(document);
|
||||||
if (!LanguageClientManager::isShuttingDown()) {
|
if (!ExtensionSystem::PluginManager::isShuttingDown()) {
|
||||||
// prevent accessing deleted editors on Creator shutdown
|
// prevent accessing deleted editors on Creator shutdown
|
||||||
const QList<Core::IEditor *> &editors = Core::DocumentModel::editorsForOpenedDocuments();
|
const QList<Core::IEditor *> &editors = Core::DocumentModel::editorsForOpenedDocuments();
|
||||||
for (Core::IEditor *editor : editors) {
|
for (Core::IEditor *editor : editors) {
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/navigationwidget.h>
|
#include <coreplugin/navigationwidget.h>
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <languageserverprotocol/messages.h>
|
#include <languageserverprotocol/messages.h>
|
||||||
#include <languageserverprotocol/progresssupport.h>
|
#include <languageserverprotocol/progresssupport.h>
|
||||||
|
|
||||||
@@ -32,6 +34,7 @@
|
|||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
using namespace ExtensionSystem;
|
||||||
using namespace LanguageServerProtocol;
|
using namespace LanguageServerProtocol;
|
||||||
|
|
||||||
namespace LanguageClient {
|
namespace LanguageClient {
|
||||||
@@ -39,7 +42,6 @@ namespace LanguageClient {
|
|||||||
static Q_LOGGING_CATEGORY(Log, "qtc.languageclient.manager", QtWarningMsg)
|
static Q_LOGGING_CATEGORY(Log, "qtc.languageclient.manager", QtWarningMsg)
|
||||||
|
|
||||||
static LanguageClientManager *managerInstance = nullptr;
|
static LanguageClientManager *managerInstance = nullptr;
|
||||||
static bool g_shuttingDown = false;
|
|
||||||
|
|
||||||
class LanguageClientManagerPrivate
|
class LanguageClientManagerPrivate
|
||||||
{
|
{
|
||||||
@@ -139,7 +141,7 @@ void LanguageClientManager::clientStarted(Client *client)
|
|||||||
QTC_ASSERT(client, return);
|
QTC_ASSERT(client, return);
|
||||||
if (client->state() != Client::Uninitialized) // do not proceed if we already received an error
|
if (client->state() != Client::Uninitialized) // do not proceed if we already received an error
|
||||||
return;
|
return;
|
||||||
if (g_shuttingDown) {
|
if (PluginManager::isShuttingDown()) {
|
||||||
clientFinished(client);
|
clientFinished(client);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -165,7 +167,7 @@ void LanguageClientManager::clientFinished(Client *client)
|
|||||||
&& client->state() != Client::ShutdownRequested;
|
&& client->state() != Client::ShutdownRequested;
|
||||||
|
|
||||||
if (unexpectedFinish) {
|
if (unexpectedFinish) {
|
||||||
if (!g_shuttingDown) {
|
if (!PluginManager::isShuttingDown()) {
|
||||||
const QList<TextEditor::TextDocument *> &clientDocs
|
const QList<TextEditor::TextDocument *> &clientDocs
|
||||||
= managerInstance->m_clientForDocument.keys(client);
|
= managerInstance->m_clientForDocument.keys(client);
|
||||||
if (client->reset()) {
|
if (client->reset()) {
|
||||||
@@ -187,7 +189,7 @@ void LanguageClientManager::clientFinished(Client *client)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteClient(client);
|
deleteClient(client);
|
||||||
if (g_shuttingDown && managerInstance->m_clients.isEmpty())
|
if (PluginManager::isShuttingDown() && managerInstance->m_clients.isEmpty())
|
||||||
emit managerInstance->shutdownFinished();
|
emit managerInstance->shutdownFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,17 +238,14 @@ void LanguageClientManager::deleteClient(Client *client)
|
|||||||
for (QList<Client *> &clients : managerInstance->m_clientsForSetting)
|
for (QList<Client *> &clients : managerInstance->m_clientsForSetting)
|
||||||
clients.removeAll(client);
|
clients.removeAll(client);
|
||||||
client->deleteLater();
|
client->deleteLater();
|
||||||
if (!g_shuttingDown)
|
if (!PluginManager::isShuttingDown())
|
||||||
emit instance()->clientRemoved(client);
|
emit instance()->clientRemoved(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LanguageClientManager::shutdown()
|
void LanguageClientManager::shutdown()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(managerInstance, return);
|
QTC_ASSERT(managerInstance, return);
|
||||||
if (g_shuttingDown)
|
|
||||||
return;
|
|
||||||
qCDebug(Log) << "shutdown manager";
|
qCDebug(Log) << "shutdown manager";
|
||||||
g_shuttingDown = true;
|
|
||||||
const auto clients = managerInstance->clients();
|
const auto clients = managerInstance->clients();
|
||||||
for (Client *client : clients)
|
for (Client *client : clients)
|
||||||
shutdownClient(client);
|
shutdownClient(client);
|
||||||
@@ -258,11 +257,6 @@ void LanguageClientManager::shutdown()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LanguageClientManager::isShuttingDown()
|
|
||||||
{
|
|
||||||
return g_shuttingDown;
|
|
||||||
}
|
|
||||||
|
|
||||||
LanguageClientManager *LanguageClientManager::instance()
|
LanguageClientManager *LanguageClientManager::instance()
|
||||||
{
|
{
|
||||||
return managerInstance;
|
return managerInstance;
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ public:
|
|||||||
static void deleteClient(Client *client);
|
static void deleteClient(Client *client);
|
||||||
|
|
||||||
static void shutdown();
|
static void shutdown();
|
||||||
static bool isShuttingDown();
|
|
||||||
|
|
||||||
static LanguageClientManager *instance();
|
static LanguageClientManager *instance();
|
||||||
|
|
||||||
|
|||||||
@@ -177,6 +177,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
using namespace ExtensionSystem;
|
||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -600,7 +601,6 @@ public:
|
|||||||
BuildPropertiesSettings m_buildPropertiesSettings;
|
BuildPropertiesSettings m_buildPropertiesSettings;
|
||||||
QList<CustomParserSettings> m_customParsers;
|
QList<CustomParserSettings> m_customParsers;
|
||||||
bool m_shouldHaveRunConfiguration = false;
|
bool m_shouldHaveRunConfiguration = false;
|
||||||
bool m_shuttingDown = false;
|
|
||||||
Id m_runMode = Constants::NO_RUN_MODE;
|
Id m_runMode = Constants::NO_RUN_MODE;
|
||||||
|
|
||||||
ToolChainManager *m_toolChainManager = nullptr;
|
ToolChainManager *m_toolChainManager = nullptr;
|
||||||
@@ -1632,11 +1632,11 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
connect(ICore::instance(), &ICore::saveSettingsRequested,
|
connect(ICore::instance(), &ICore::saveSettingsRequested,
|
||||||
dd, &ProjectExplorerPluginPrivate::savePersistentSettings);
|
dd, &ProjectExplorerPluginPrivate::savePersistentSettings);
|
||||||
connect(EditorManager::instance(), &EditorManager::autoSaved, this, [] {
|
connect(EditorManager::instance(), &EditorManager::autoSaved, this, [] {
|
||||||
if (!dd->m_shuttingDown && !SessionManager::loadingSession())
|
if (!PluginManager::isShuttingDown() && !SessionManager::loadingSession())
|
||||||
SessionManager::saveSession();
|
SessionManager::saveSession();
|
||||||
});
|
});
|
||||||
connect(qApp, &QApplication::applicationStateChanged, this, [](Qt::ApplicationState state) {
|
connect(qApp, &QApplication::applicationStateChanged, this, [](Qt::ApplicationState state) {
|
||||||
if (!dd->m_shuttingDown && state == Qt::ApplicationActive)
|
if (!PluginManager::isShuttingDown() && state == Qt::ApplicationActive)
|
||||||
dd->updateWelcomePage();
|
dd->updateWelcomePage();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2173,7 +2173,7 @@ void ProjectExplorerPluginPrivate::updateRunWithoutDeployMenu()
|
|||||||
m_runWithoutDeployAction->setVisible(m_projectExplorerSettings.deployBeforeRun);
|
m_runWithoutDeployAction->setVisible(m_projectExplorerSettings.deployBeforeRun);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown()
|
IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown()
|
||||||
{
|
{
|
||||||
disconnect(ModeManager::instance(), &ModeManager::currentModeChanged,
|
disconnect(ModeManager::instance(), &ModeManager::currentModeChanged,
|
||||||
dd, &ProjectExplorerPluginPrivate::currentModeChanged);
|
dd, &ProjectExplorerPluginPrivate::currentModeChanged);
|
||||||
@@ -2181,8 +2181,6 @@ ExtensionSystem::IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown()
|
|||||||
ToolChainManager::aboutToShutdown();
|
ToolChainManager::aboutToShutdown();
|
||||||
ProjectManager::closeAllProjects();
|
ProjectManager::closeAllProjects();
|
||||||
|
|
||||||
dd->m_shuttingDown = true;
|
|
||||||
|
|
||||||
// Attempt to synchronously shutdown all run controls.
|
// Attempt to synchronously shutdown all run controls.
|
||||||
// If that fails, fall back to asynchronous shutdown (Debugger run controls
|
// If that fails, fall back to asynchronous shutdown (Debugger run controls
|
||||||
// might shutdown asynchronously).
|
// might shutdown asynchronously).
|
||||||
@@ -2251,7 +2249,7 @@ bool ProjectExplorerPluginPrivate::closeAllFilesInProject(const Project *project
|
|||||||
|
|
||||||
void ProjectExplorerPluginPrivate::savePersistentSettings()
|
void ProjectExplorerPluginPrivate::savePersistentSettings()
|
||||||
{
|
{
|
||||||
if (dd->m_shuttingDown)
|
if (PluginManager::isShuttingDown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!SessionManager::loadingSession()) {
|
if (!SessionManager::loadingSession()) {
|
||||||
@@ -2560,7 +2558,7 @@ void ProjectExplorerPluginPrivate::checkForShutdown()
|
|||||||
{
|
{
|
||||||
--m_activeRunControlCount;
|
--m_activeRunControlCount;
|
||||||
QTC_ASSERT(m_activeRunControlCount >= 0, m_activeRunControlCount = 0);
|
QTC_ASSERT(m_activeRunControlCount >= 0, m_activeRunControlCount = 0);
|
||||||
if (m_shuttingDown && m_activeRunControlCount == 0)
|
if (PluginManager::isShuttingDown() && m_activeRunControlCount == 0)
|
||||||
emit m_instance->asynchronousShutdownFinished();
|
emit m_instance->asynchronousShutdownFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -210,11 +210,6 @@ void QmlJSEditorPlugin::extensionsInitialized()
|
|||||||
QmllsSettingsManager::instance()->setupAutoupdate();
|
QmllsSettingsManager::instance()->setupAutoupdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag QmlJSEditorPlugin::aboutToShutdown()
|
|
||||||
{
|
|
||||||
return IPlugin::aboutToShutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils::JsonSchemaManager *QmlJSEditorPlugin::jsonManager()
|
Utils::JsonSchemaManager *QmlJSEditorPlugin::jsonManager()
|
||||||
{
|
{
|
||||||
return &m_instance->d->m_jsonManager;
|
return &m_instance->d->m_jsonManager;
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
void initialize() final;
|
void initialize() final;
|
||||||
void extensionsInitialized() final;
|
void extensionsInitialized() final;
|
||||||
ShutdownFlag aboutToShutdown() final;
|
|
||||||
|
|
||||||
class QmlJSEditorPluginPrivate *d = nullptr;
|
class QmlJSEditorPluginPrivate *d = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user