History

fix interactive window crash

dante ruiz committed 7 years ago

Commit 7c024b41 parent 57c820f3 files · +45 −90Browse files

Showing the changes to interface/src/scripting/DesktopScriptingInterface.cpp (1 of 3 files). Show all

Unified · Split

interface/src/scripting/DesktopScriptingInterface.cpp+17−2
@@ -111,10 +111,11 @@ void DesktopScriptingInterface::show(const QString& path, const QString& title) · 110 unmodified lines
111111 InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& sourceUrl, const QVariantMap& properties) {
112112 if (QThread::currentThread() != thread()) {
113113 InteractiveWindowPointer interactiveWindow = nullptr;
114− BLOCKING_INVOKE_METHOD(this, "createWindow",
114+ BLOCKING_INVOKE_METHOD(this, "createWindowOnThread",
115115 Q_RETURN_ARG(InteractiveWindowPointer, interactiveWindow),
116116 Q_ARG(QString, sourceUrl),
117− Q_ARG(QVariantMap, properties));
117+ Q_ARG(QVariantMap, properties),
118+ Q_ARG(QThread*, QThread::currentThread()));
118119 return interactiveWindow;
119120 }
120121
@@ -129,3 +130,17 @@ InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& · 8 unmodified lines
129130
130131 return new InteractiveWindow(sourceUrl, properties);
131132 }
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+}