From a6e6c88ed837172debce92771caa721b9e7baee5 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 27 Jan 2016 22:36:48 +0200 Subject: [PATCH] Revert "QmlJS: Exchange unsafe meta calls with QTimer::singleShot" QTimer::singleShot with a member function pointer or a lambda does not schedule the invocation directly on the receivers event loop, even if the timeout is 0. It actually creates a timer in the thread where QTimer::singleShot is called, which requires an event dispatcher to be available. Only the timer's timeout() signal then schedules the invocation on the receivers thread. We do not want to actually run an event loop here until a timer fires. Even if a timer with timeout 0 might directly schedule the timeout event on the event dispatcher without involving actual timers, and even if that event dispatcher makes sure all events are handled before deleting itself, it would feel like relying on an implementation detail. This reverts commit a2e19ba1bec09294c7588a97722195cc390ea7a3. Task-number: QTCREATORBUG-15681 Change-Id: I19846ce089d72c971d3cc5927c2ddf563e06de14 Reviewed-by: Eike Ziller --- src/libs/qmljs/qmljsmodelmanagerinterface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index 9430935ccf4..a5b6e39fd2d 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -1216,7 +1217,8 @@ void ModelManagerInterface::maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document doc->releaseSourceAndAST(); // delegate actual queuing to the gui thread - QTimer::singleShot(0, this, [this, doc, scan]() { queueCppQmlTypeUpdate(doc, scan); }); + QMetaObject::invokeMethod(this, "queueCppQmlTypeUpdate", + Q_ARG(CPlusPlus::Document::Ptr, doc), Q_ARG(bool, scan)); } void ModelManagerInterface::queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc, bool scan) @@ -1315,7 +1317,7 @@ void ModelManagerInterface::updateCppQmlTypes(QFutureInterface &interface, qmlModelManager->m_cppDataHash = newData; if (hasNewInfo) // one could get away with re-linking the cpp types... - QTimer::singleShot(0, qmlModelManager, &ModelManagerInterface::asyncReset); + QMetaObject::invokeMethod(qmlModelManager, "asyncReset"); } ModelManagerInterface::CppDataHash ModelManagerInterface::cppData() const