forked from qt-creator/qt-creator
Synchronize all started threads in SemanticHighlighter d'tor
This fixes a possible crash on session switch or on shutdown. Task-number: QTCREATORBUG-25708 Change-Id: I5dcc2420dca27b9856f47616c6f465ae8f059942 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -560,8 +560,10 @@ void SemanticHighlighter::rerun(const QmlJSTools::SemanticInfo &semanticInfo)
|
|||||||
m_watcher.cancel();
|
m_watcher.cancel();
|
||||||
|
|
||||||
m_startRevision = m_document->document()->revision();
|
m_startRevision = m_document->document()->revision();
|
||||||
m_watcher.setFuture(Utils::runAsync(QThread::LowestPriority,
|
auto future = Utils::runAsync(QThread::LowestPriority, &SemanticHighlighter::run,
|
||||||
&SemanticHighlighter::run, this, semanticInfo));
|
this, semanticInfo);
|
||||||
|
m_watcher.setFuture(future);
|
||||||
|
m_futureSynchronizer.addFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SemanticHighlighter::cancel()
|
void SemanticHighlighter::cancel()
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <qmljseditor/qmljseditor_global.h>
|
#include <qmljseditor/qmljseditor_global.h>
|
||||||
#include <texteditor/semantichighlighter.h>
|
#include <texteditor/semantichighlighter.h>
|
||||||
|
#include <QFutureSynchronizer>
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QTextLayout>
|
#include <QTextLayout>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
@@ -89,6 +90,7 @@ private:
|
|||||||
QHash<int, QTextCharFormat> m_formats;
|
QHash<int, QTextCharFormat> m_formats;
|
||||||
QHash<int, QTextCharFormat> m_extraFormats;
|
QHash<int, QTextCharFormat> m_extraFormats;
|
||||||
QVector<QTextLayout::FormatRange> m_diagnosticRanges;
|
QVector<QTextLayout::FormatRange> m_diagnosticRanges;
|
||||||
|
QFutureSynchronizer<void> m_futureSynchronizer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlJSEditor
|
} // namespace QmlJSEditor
|
||||||
|
Reference in New Issue
Block a user