Showing the changes to interface/src/scripting/DesktopScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -111,10 +111,11 @@ void DesktopScriptingInterface::show(const QString& path, const QString& title) · 110 unmodified lines | ||
| 111 | 111 | InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& sourceUrl, const QVariantMap& properties) { |
| 112 | 112 | if (QThread::currentThread() != thread()) { |
| 113 | 113 | InteractiveWindowPointer interactiveWindow = nullptr; |
| 114 | − BLOCKING_INVOKE_METHOD(this, "createWindow", | |
| 114 | + BLOCKING_INVOKE_METHOD(this, "createWindowOnThread", | |
| 115 | 115 | Q_RETURN_ARG(InteractiveWindowPointer, interactiveWindow), |
| 116 | 116 | Q_ARG(QString, sourceUrl), |
| 117 | − Q_ARG(QVariantMap, properties)); | |
| 117 | + Q_ARG(QVariantMap, properties), | |
| 118 | + Q_ARG(QThread*, QThread::currentThread())); | |
| 118 | 119 | return interactiveWindow; |
| 119 | 120 | } |
| 120 | 121 | |
| @@ -129,3 +130,17 @@ InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& · 8 unmodified lines | ||
| 129 | 130 | |
| 130 | 131 | return new InteractiveWindow(sourceUrl, properties); |
| 131 | 132 | } |
| 133 | + | |
| 134 | +InteractiveWindowPointer DesktopScriptingInterface::createWindowOnThread(const QString& sourceUrl, const QVariantMap& properties, QThread* targetThread) { | |
| 135 | + | |
| 136 | + // The offscreen surface already validates against non-local QML sources, but we also need to ensure that | |
| 137 | + // if we create top level QML, like dock widgets or other types of QQuickView containing desktop windows | |
| 138 | + // that the source URL is permitted | |
| 139 | + const auto& urlValidator = OffscreenQmlSurface::getUrlValidator(); | |
| 140 | + if (!urlValidator(sourceUrl)) { | |
| 141 | + return nullptr; | |
| 142 | + } | |
| 143 | + InteractiveWindowPointer window = new InteractiveWindow(sourceUrl, properties); | |
| 144 | + window->moveToThread(targetThread); | |
| 145 | + return window; | |
| 146 | +} | |