forked from qt-creator/qt-creator
Utils: Introduce GlobalFileChangeBlocker
Tracks application state, and signals when it is changed. Supports forcing blocked state with reference counting. Change-Id: Ic173d42446b1b08bd4a1e7c1acf38c68644d30b3 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
81ce096719
commit
c225216b93
@@ -48,6 +48,7 @@
|
||||
#include <clangsupport/filecontainer.h>
|
||||
#include <clangsupport/clangcodemodelservermessages.h>
|
||||
|
||||
#include <utils/globalfilechangeblocker.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDateTime>
|
||||
@@ -104,6 +105,10 @@ BackendCommunicator::BackendCommunicator()
|
||||
this, &BackendCommunicator::onEditorAboutToClose);
|
||||
connect(Core::ICore::instance(), &Core::ICore::coreAboutToClose,
|
||||
this, &BackendCommunicator::setupDummySender);
|
||||
auto globalFCB = ::Utils::GlobalFileChangeBlocker::instance();
|
||||
m_postponeBackendJobs = globalFCB->isBlocked();
|
||||
connect(globalFCB, &::Utils::GlobalFileChangeBlocker::stateChanged,
|
||||
this, &BackendCommunicator::setBackendJobsPostponed);
|
||||
|
||||
initializeBackend();
|
||||
}
|
||||
@@ -210,14 +215,11 @@ bool BackendCommunicator::isNotWaitingForCompletion() const
|
||||
void BackendCommunicator::setBackendJobsPostponed(bool postponed)
|
||||
{
|
||||
if (postponed) {
|
||||
if (!m_postponeBackendJobs)
|
||||
documentVisibilityChanged(Utf8String(), {});
|
||||
++m_postponeBackendJobs;
|
||||
documentVisibilityChanged(Utf8String(), {});
|
||||
m_postponeBackendJobs = postponed;
|
||||
} else {
|
||||
if (QTC_GUARD(m_postponeBackendJobs > 0))
|
||||
--m_postponeBackendJobs;
|
||||
if (!m_postponeBackendJobs)
|
||||
documentVisibilityChanged();
|
||||
m_postponeBackendJobs = postponed;
|
||||
documentVisibilityChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user