Last active
December 18, 2019 14:32
-
-
Save AlbertoMarnetto/17eab1836e573dffd9c10b0bae7befa1 to your computer and use it in GitHub Desktop.
Patch for Qt creator, commit afbcdb33a810e1cc1a95f77d0c4c74ae581c5c1a, to build with Qt 5.9 (5.11 would be required otherwise)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 207bbc47003c749e1ce27fe2599a1a03a718c60f Mon Sep 17 00:00:00 2001 | |
| From: Alberto Marnetto <alberto.marnetto@indurad.com> | |
| Date: Mon, 11 Feb 2019 13:49:40 +0100 | |
| Subject: [PATCH] t | |
| ### Apply on the following commit: | |
| ### From: Thomas Hartmann <thomas.hartmann@qt.io> | |
| ### Date: Wed, 30 Jan 2019 15:14:48 +0100 | |
| ### Subject: [PATCH] QmlDesigner: Avoid internal warnings | |
| ### Change-Id: I20c9d77a6758e70b138f9fec30a6845354d20880 | |
| ### Reviewed-by: Knud Dollereder <knud.dollereder@qt.io> | |
| ### Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> | |
| --- | |
| .../source/taskscheduler.h | 84 ++++++++++--------- | |
| 1 file changed, 43 insertions(+), 41 deletions(-) | |
| diff --git a/src/tools/clangpchmanagerbackend/source/taskscheduler.h b/src/tools/clangpchmanagerbackend/source/taskscheduler.h | |
| index 37fdc744a..09e1c9abb 100644 | |
| --- a/src/tools/clangpchmanagerbackend/source/taskscheduler.h | |
| +++ b/src/tools/clangpchmanagerbackend/source/taskscheduler.h | |
| @@ -37,6 +37,7 @@ | |
| #include <QAbstractEventDispatcher> | |
| #include <QCoreApplication> | |
| #include <QMetaObject> | |
| +#include <QObject> | |
| #include <QThread> | |
| #include <algorithm> | |
| @@ -85,12 +86,53 @@ public: | |
| syncTasks(); | |
| } | |
| + template <typename CallableType> | |
| + class CallableEvent : public QEvent { | |
| + public: | |
| + using Callable = std::decay_t<CallableType>; | |
| + CallableEvent(Callable &&callable) | |
| + : QEvent(QEvent::None), | |
| + callable(std::move(callable)) | |
| + {} | |
| + CallableEvent(const Callable &callable) | |
| + : QEvent(QEvent::None), | |
| + callable(callable) | |
| + {} | |
| + | |
| + ~CallableEvent() | |
| + { | |
| + callable(); | |
| + } | |
| + public: | |
| + Callable callable; | |
| + }; | |
| + | |
| + template <typename CallableType> | |
| + void executeInLoop(CallableType &&callable, QObject *object = QCoreApplication::instance()) | |
| + { | |
| + if (QThread *thread = qobject_cast<QThread*>(object)) | |
| + object = QAbstractEventDispatcher::instance(thread); | |
| + | |
| + QCoreApplication::postEvent(object, | |
| + new CallableEvent<CallableType>(std::forward<CallableType>(callable)), | |
| + Qt::HighEventPriority); | |
| + } | |
| + | |
| void addTasks(std::vector<Task> &&tasks) | |
| { | |
| for (auto &task : tasks) { | |
| auto callWrapper = [&, task = std::move(task)](auto processor) -> ProcessorInterface & { | |
| task(processor.get()); | |
| - executeInLoop([&] { m_queue.processEntries(); }); | |
| + auto processCallable = [&] { m_queue.processEntries(); }; | |
| + { | |
| + QObject *object = QCoreApplication::instance(); | |
| + if (QThread *thread = qobject_cast<QThread*>(object)) | |
| + object = QAbstractEventDispatcher::instance(thread); | |
| + | |
| + QCoreApplication::postEvent(object, | |
| + new CallableEvent<decltype(processCallable)>(processCallable), | |
| + Qt::HighEventPriority); | |
| + } | |
| return processor; | |
| }; | |
| @@ -149,46 +191,6 @@ private: | |
| m_futures.erase(split, m_futures.end()); | |
| } | |
| - #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) | |
| - template <typename CallableType> | |
| - class CallableEvent : public QEvent { | |
| - public: | |
| - using Callable = std::decay_t<CallableType>; | |
| - CallableEvent(Callable &&callable) | |
| - : QEvent(QEvent::None), | |
| - callable(std::move(callable)) | |
| - {} | |
| - CallableEvent(const Callable &callable) | |
| - : QEvent(QEvent::None), | |
| - callable(callable) | |
| - {} | |
| - | |
| - ~CallableEvent() | |
| - { | |
| - callable(); | |
| - } | |
| - public: | |
| - Callable callable; | |
| - }; | |
| - | |
| - template <typename Callable> | |
| - void executeInLoop(Callable &&callable, QObject *object = QCoreApplication::instance()) { | |
| - if (QThread *thread = qobject_cast<QThread*>(object)) | |
| - object = QAbstractEventDispatcher::instance(thread); | |
| - | |
| - QCoreApplication::postEvent(object, | |
| - new CallableEvent<Callable>(std::forward<Callable>(callable)), | |
| - Qt::HighEventPriority); | |
| - } | |
| - #else | |
| - template <typename Callable> | |
| - void executeInLoop(Callable &&callable, QObject *object = QCoreApplication::instance()) { | |
| - if (QThread *thread = qobject_cast<QThread*>(object)) | |
| - object = QAbstractEventDispatcher::instance(thread); | |
| - | |
| - QMetaObject::invokeMethod(object, std::forward<Callable>(callable)); | |
| - } | |
| - #endif | |
| private: | |
| std::vector<Future> m_futures; | |
| -- | |
| 2.22.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment