From f10f0b73d4f6530c6531effeb8d2b312d430f4eb Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 16 Feb 2015 15:14:21 +0100 Subject: [PATCH] ClearCase: Do not use ProjectTree::currentProject That is almost certainly not what you want:-) Use SessionManager::startupProject instead. Also use state changed from QApplication in favor of having the mainwindow notify us about updates. That does no longer work, now that we have multiple windows. Change-Id: I27563c8e060ea154c0db5e5777d4b92840f31fa7 Reviewed-by: Orgad Shaneh Reviewed-by: Eike Ziller --- src/plugins/clearcase/clearcaseplugin.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index 7217c6ae59e..524c430837a 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -55,7 +55,7 @@ #include #include #include -#include +#include #include #include #include @@ -195,6 +195,11 @@ ClearCasePlugin::ClearCasePlugin() : #endif { qRegisterMetaType("ClearCase::Internal::FileStatus::Status"); + connect(qApp, &QApplication::applicationStateChanged, + this, [this](Qt::ApplicationState state) { + if (state == Qt::ApplicationActive) + syncSlot(); + }); } ClearCasePlugin::~ClearCasePlugin() @@ -454,7 +459,7 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er m_settings.fromSettings(ICore::settings()); // update view name when changing active project - connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged, + connect(SessionManager::instance(), &SessionManager::startupProjectChanged, this, &ClearCasePlugin::projectChanged); addAutoReleasedObject(new SettingsPage); @@ -2028,7 +2033,6 @@ void ClearCasePlugin::projectChanged(Project *project) m_viewData = ViewData(); m_stream.clear(); m_intStream.clear(); - disconnect(ICore::mainWindow(), SIGNAL(windowActivated()), this, SLOT(syncSlot())); ProgressManager::cancelTasks(ClearCase::Constants::TASK_INDEX); if (project) { QString projDir = project->projectDirectory().toString(); @@ -2056,7 +2060,7 @@ void ClearCasePlugin::updateIndex() { QTC_ASSERT(currentState().hasTopLevel(), return); ProgressManager::cancelTasks(ClearCase::Constants::TASK_INDEX); - Project *project = ProjectTree::currentProject(); + Project *project = SessionManager::startupProject(); if (!project) return; m_checkInAllAction->setEnabled(false); @@ -2207,7 +2211,7 @@ void ClearCasePlugin::closing() { // prevent syncSlot from being called on shutdown ProgressManager::cancelTasks(ClearCase::Constants::TASK_INDEX); - disconnect(ICore::mainWindow(), SIGNAL(windowActivated()), this, SLOT(syncSlot())); + disconnect(qApp, &QApplication::applicationStateChanged, 0, 0); } void ClearCasePlugin::sync(QFutureInterface &future, QStringList files)