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:
Orgad Shaneh
2018-12-16 00:32:14 +02:00
committed by Orgad Shaneh
parent 81ce096719
commit c225216b93
15 changed files with 152 additions and 71 deletions

View File

@@ -29,7 +29,7 @@
#include <coreplugin/documentmanager.h>
#include <coreplugin/vcsmanager.h>
#include <cpptools/cppmodelmanager.h>
#include <utils/globalfilechangeblocker.h>
#include <utils/synchronousprocess.h>
#include <QProcessEnvironment>
@@ -61,16 +61,12 @@ VcsCommand::VcsCommand(const QString &workingDirectory,
return proxy;
});
connect(this, &VcsCommand::started, this, [this] {
if (flags() & ExpectRepoChanges) {
Core::DocumentManager::setAutoReloadPostponed(true);
CppTools::CppModelManager::instance()->setBackendJobsPostponed(true);
}
if (flags() & ExpectRepoChanges)
Utils::GlobalFileChangeBlocker::instance()->forceBlocked(true);
});
connect(this, &VcsCommand::finished, this, [this] {
if (flags() & ExpectRepoChanges) {
Core::DocumentManager::setAutoReloadPostponed(false);
CppTools::CppModelManager::instance()->setBackendJobsPostponed(false);
}
if (flags() & ExpectRepoChanges)
Utils::GlobalFileChangeBlocker::instance()->forceBlocked(false);
});
}