Showing the changes to interface/src/scripting/ToolbarScriptingInterface.cpp (1 of 1 file). Show all
Unified · Split
| @@ -8,6 +8,8 @@ · 7 unmodified lines | |||
| 8 | 8 | ||
| 9 | #include "ToolbarScriptingInterface.h" | 9 | #include "ToolbarScriptingInterface.h" |
| 10 | 10 | ||
| 11 | #include <QtCore/QThread> | ||
| 12 | |||
| 11 | #include <OffscreenUi.h> | 13 | #include <OffscreenUi.h> |
| 12 | 14 | ||
| 13 | class QmlWrapper : public QObject { | 15 | class QmlWrapper : public QObject { |
| @@ -79,7 +81,11 @@ public: · 65 unmodified lines | |||
| 79 | 81 | ||
| 80 | Q_INVOKABLE QObject* addButton(const QVariant& properties) { | 82 | Q_INVOKABLE QObject* addButton(const QVariant& properties) { |
| 81 | QVariant resultVar; | 83 | QVariant resultVar; |
| 82 | bool invokeResult = QMetaObject::invokeMethod(_qmlObject, "addButton", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QVariant, resultVar), Q_ARG(QVariant, properties)); | 84 | Qt::ConnectionType connectionType = Qt::AutoConnection; |
| 85 | if (QThread::currentThread() != _qmlObject->thread()) { | ||
| 86 | connectionType = Qt::BlockingQueuedConnection; | ||
| 87 | } | ||
| 88 | bool invokeResult = QMetaObject::invokeMethod(_qmlObject, "addButton", connectionType, Q_RETURN_ARG(QVariant, resultVar), Q_ARG(QVariant, properties)); | ||
| 83 | if (!invokeResult) { | 89 | if (!invokeResult) { |
| 84 | return nullptr; | 90 | return nullptr; |
| 85 | } | 91 | } |
| @@ -101,8 +107,12 @@ public: · 15 unmodified lines | |||
| 101 | QObject* ToolbarScriptingInterface::getToolbar(const QString& toolbarId) { | 107 | QObject* ToolbarScriptingInterface::getToolbar(const QString& toolbarId) { |
| 102 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 108 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 103 | auto desktop = offscreenUi->getDesktop(); | 109 | auto desktop = offscreenUi->getDesktop(); |
| 110 | Qt::ConnectionType connectionType = Qt::AutoConnection; | ||
| 111 | if (QThread::currentThread() != desktop->thread()) { | ||
| 112 | connectionType = Qt::BlockingQueuedConnection; | ||
| 113 | } | ||
| 104 | QVariant resultVar; | 114 | QVariant resultVar; |
| 105 | bool invokeResult = QMetaObject::invokeMethod(desktop, "getToolbar", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QVariant, resultVar), Q_ARG(QVariant, toolbarId)); | 115 | bool invokeResult = QMetaObject::invokeMethod(desktop, "getToolbar", connectionType, Q_RETURN_ARG(QVariant, resultVar), Q_ARG(QVariant, toolbarId)); |
| 106 | if (!invokeResult) { | 116 | if (!invokeResult) { |
| 107 | return nullptr; | 117 | return nullptr; |
| 108 | } | 118 | } |