diff --git a/src/plugins/help/helpmanager.cpp b/src/plugins/help/helpmanager.cpp index c3e0bd31512..69fe0dabf9e 100644 --- a/src/plugins/help/helpmanager.cpp +++ b/src/plugins/help/helpmanager.cpp @@ -7,7 +7,9 @@ #include #include + #include +#include #include #include #include @@ -17,6 +19,7 @@ #include #include #include +#include #include #include @@ -99,7 +102,7 @@ void HelpManager::registerDocumentation(const QStringList &files) return; } - QFuture future = Utils::runAsync(&HelpManager::registerDocumentationNow, files); + QFuture future = Utils::asyncRun(&HelpManager::registerDocumentationNow, files); Utils::onResultReady(future, this, [](bool docsChanged){ if (docsChanged) { d->m_helpEngine->setupData(); @@ -122,13 +125,12 @@ void HelpManager::unregisterDocumentation(const QStringList &fileNames) unregisterNamespaces(getNamespaces(fileNames)); } -void HelpManager::registerDocumentationNow(QFutureInterface &futureInterface, - const QStringList &files) +void HelpManager::registerDocumentationNow(QPromise &promise, const QStringList &files) { QMutexLocker locker(&d->m_helpengineMutex); - futureInterface.setProgressRange(0, files.count()); - futureInterface.setProgressValue(0); + promise.setProgressRange(0, files.count()); + promise.setProgressValue(0); QHelpEngineCore helpEngine(collectionFilePath()); helpEngine.setReadOnly(false); @@ -136,9 +138,9 @@ void HelpManager::registerDocumentationNow(QFutureInterface &futureInterfa bool docsChanged = false; QStringList nameSpaces = helpEngine.registeredDocumentations(); for (const QString &file : files) { - if (futureInterface.isCanceled()) + if (promise.isCanceled()) break; - futureInterface.setProgressValue(futureInterface.progressValue() + 1); + promise.setProgressValue(promise.future().progressValue() + 1); const QString &nameSpace = QHelpEngineCore::namespaceName(file); if (nameSpace.isEmpty()) continue; @@ -152,7 +154,7 @@ void HelpManager::registerDocumentationNow(QFutureInterface &futureInterfa } } } - futureInterface.reportResult(docsChanged); + promise.addResult(docsChanged); } void HelpManager::unregisterNamespaces(const QStringList &nameSpaces) diff --git a/src/plugins/help/helpmanager.h b/src/plugins/help/helpmanager.h index d868e96256e..6ab3e72cd97 100644 --- a/src/plugins/help/helpmanager.h +++ b/src/plugins/help/helpmanager.h @@ -5,12 +5,16 @@ #include -QT_FORWARD_DECLARE_CLASS(QUrl) - #include #include #include +QT_BEGIN_NAMESPACE +template +class QPromise; +class QUrl; +QT_END_NAMESPACE + namespace Help { namespace Internal { @@ -55,10 +59,9 @@ public: const QUrl &url, Core::HelpManager::HelpViewerLocation location = Core::HelpManager::HelpModeAlways) override; - static void setupHelpManager(); - static void registerDocumentationNow(QFutureInterface &futureInterface, - const QStringList &fileNames); + static void registerDocumentationNow(QPromise &promise, const QStringList &fileNames); + signals: void collectionFileChanged(); void helpRequested(const QUrl &url, Core::HelpManager::HelpViewerLocation location);