diff options
author | Eike Ziller <eike.ziller@theqtcompany.com> | 2016-02-02 09:19:56 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@theqtcompany.com> | 2016-02-03 15:06:36 +0000 |
commit | cbd5f8e905fc344d0e186c0251884560d9ca5242 (patch) | |
tree | daa3f876334b3a73a487d8e4c66a609f52d6924a /src/plugins/texteditor | |
parent | b19cac022ee4e80aefe04f66d58673fb174f6533 (diff) | |
download | qt-creator-cbd5f8e905fc344d0e186c0251884560d9ca5242.tar.gz |
Generic highlighter: Use runAsync and avoid deleteLater
There is no need for the highlight files processor to be a Q_OBJECT, and
it can also be created on the stack (and moved to the thread).
Change-Id: Ic347b1b7e5ece50642b85654fb2701fe5994619b
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r-- | src/plugins/texteditor/generichighlighter/manager.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/plugins/texteditor/generichighlighter/manager.cpp b/src/plugins/texteditor/generichighlighter/manager.cpp index 17329587a5..6286e2927a 100644 --- a/src/plugins/texteditor/generichighlighter/manager.cpp +++ b/src/plugins/texteditor/generichighlighter/manager.cpp @@ -248,12 +248,13 @@ bool Manager::isBuildingDefinition(const QString &id) const return m_isBuildingDefinition.contains(id); } -class ManagerProcessor : public QObject +class ManagerProcessor { - Q_OBJECT public: ManagerProcessor(); - void process(QFutureInterface<Manager::RegisterData> &future); + // TODO: make move-only when we can require MSVC2015 + + void operator()(QFutureInterface<Manager::RegisterData> &future); QStringList m_definitionsPaths; static const int kMaxProgress; @@ -269,7 +270,7 @@ ManagerProcessor::ManagerProcessor() m_definitionsPaths.append(settings.fallbackDefinitionFilesPath()); } -void ManagerProcessor::process(QFutureInterface<Manager::RegisterData> &future) +void ManagerProcessor::operator()(QFutureInterface<Manager::RegisterData> &future) { future.setProgressRange(0, kMaxProgress); @@ -321,11 +322,7 @@ void Manager::registerHighlightingFiles() if (!m_registeringWatcher.isRunning()) { clear(); - ManagerProcessor *processor = new ManagerProcessor; - QFuture<RegisterData> future = - QtConcurrent::run(&ManagerProcessor::process, processor); - connect(&m_registeringWatcher, &QFutureWatcherBase::finished, - processor, &QObject::deleteLater); + QFuture<RegisterData> future = Utils::runAsync<RegisterData>(ManagerProcessor()); m_registeringWatcher.setFuture(future); } else { m_hasQueuedRegistration = true; |