forked from qt-creator/qt-creator
Core: cancel async documentation registration on shutdown
Change-Id: I46bc81cf6326e964309996e0e205fff011f596e7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
committed by
Christian Stenger
parent
075d636655
commit
63cc5491f5
@@ -275,5 +275,6 @@ ExtensionSystem::IPlugin::ShutdownFlag CorePlugin::aboutToShutdown()
|
||||
{
|
||||
Find::aboutToShutdown();
|
||||
m_mainWindow->aboutToShutdown();
|
||||
HelpManager::aboutToShutdown();
|
||||
return SynchronousShutdown;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,8 @@ struct HelpManagerPrivate
|
||||
|
||||
QSet<QString> m_userRegisteredFiles;
|
||||
|
||||
QMutex helpengineMutex;
|
||||
QMutex m_helpengineMutex;
|
||||
QFuture<bool> m_registerFuture;
|
||||
};
|
||||
|
||||
static HelpManager *m_instance = nullptr;
|
||||
@@ -149,7 +150,7 @@ void HelpManager::registerDocumentation(const QStringList &files)
|
||||
void HelpManager::registerDocumentationNow(QFutureInterface<bool> &futureInterface,
|
||||
const QStringList &files)
|
||||
{
|
||||
QMutexLocker locker(&d->helpengineMutex);
|
||||
QMutexLocker locker(&d->m_helpengineMutex);
|
||||
|
||||
futureInterface.setProgressRange(0, files.count());
|
||||
futureInterface.setProgressValue(0);
|
||||
@@ -157,6 +158,8 @@ void HelpManager::registerDocumentationNow(QFutureInterface<bool> &futureInterfa
|
||||
QHelpEngineCore helpEngine(collectionFilePath());
|
||||
bool docsChanged = false;
|
||||
for (const QString &file : files) {
|
||||
if (futureInterface.isCanceled())
|
||||
break;
|
||||
futureInterface.setProgressValue(futureInterface.progressValue() + 1);
|
||||
const QString &nameSpace = helpEngine.namespaceName(file);
|
||||
if (nameSpace.isEmpty())
|
||||
@@ -193,7 +196,7 @@ void HelpManager::unregisterDocumentation(const QStringList &nameSpaces)
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker locker(&d->helpengineMutex);
|
||||
QMutexLocker locker(&d->m_helpengineMutex);
|
||||
bool docsChanged = false;
|
||||
for (const QString &nameSpace : nameSpaces) {
|
||||
const QString filePath = d->m_helpEngine->documentationFileName(nameSpace);
|
||||
@@ -396,6 +399,14 @@ void HelpManager::addUserDefinedFilter(const QString &filter, const QStringList
|
||||
emit m_instance->collectionFileChanged();
|
||||
}
|
||||
|
||||
void HelpManager::aboutToShutdown()
|
||||
{
|
||||
if (d && d->m_registerFuture.isRunning()) {
|
||||
d->m_registerFuture.cancel();
|
||||
d->m_registerFuture.waitForFinished();
|
||||
}
|
||||
}
|
||||
|
||||
// -- private
|
||||
|
||||
void HelpManager::setupHelpManager()
|
||||
|
||||
@@ -87,6 +87,8 @@ public:
|
||||
static void removeUserDefinedFilter(const QString &filter);
|
||||
static void addUserDefinedFilter(const QString &filter, const QStringList &attr);
|
||||
|
||||
static void aboutToShutdown();
|
||||
|
||||
public slots:
|
||||
static void handleHelpRequest(const QUrl &url,
|
||||
Core::HelpManager::HelpViewerLocation location = HelpModeAlways);
|
||||
|
||||
Reference in New Issue
Block a user