Commit cbd5f8e9 authored by Eike Ziller's avatar Eike Ziller

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: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent b19cac02
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment