From e896a531132914c4735c9882506eaf76322e0e3c Mon Sep 17 00:00:00 2001 From: dante ruiz Date: Mon, 15 Jul 2019 17:18:38 -0700 Subject: [PATCH] fix interactive crash --- .../scripting/DesktopScriptingInterface.cpp | 1 - interface/src/ui/InteractiveWindow.cpp | 34 +++++++------------ 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/interface/src/scripting/DesktopScriptingInterface.cpp b/interface/src/scripting/DesktopScriptingInterface.cpp index 678e698033..a1c8e4fc6c 100644 --- a/interface/src/scripting/DesktopScriptingInterface.cpp +++ b/interface/src/scripting/DesktopScriptingInterface.cpp @@ -132,7 +132,6 @@ InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& } InteractiveWindowPointer DesktopScriptingInterface::createWindowOnThread(const QString& sourceUrl, const QVariantMap& properties, QThread* targetThread) { - // The offscreen surface already validates against non-local QML sources, but we also need to ensure that // if we create top level QML, like dock widgets or other types of QQuickView containing desktop windows // that the source URL is permitted diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index dff1f4dcb5..fc2d8c56bf 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -293,7 +293,11 @@ void InteractiveWindow::close() { if (_dockWidget) { auto window = qApp->getWindow(); - BLOCKING_INVOKE_METHOD(window, "removeDockWidget", Q_ARG(QDockWidget*, _dockWidget.get())); + if (QThread::currentThread() != window->thread()) { + BLOCKING_INVOKE_METHOD(window, "removeDockWidget", Q_ARG(QDockWidget*, _dockWidget.get())); + } else { + window->removeDockWidget(_dockWidget.get()); + } } _dockWidget = nullptr; _qmlWindowProxy = nullptr; @@ -332,10 +336,8 @@ bool InteractiveWindow::isVisible() const { if (!_qmlWindowProxy) { return false; } - QVariant result; - BLOCKING_INVOKE_METHOD(_qmlWindowProxy.get(), "readProperty", Q_RETURN_ARG(QVariant, result), - Q_ARG(QString, INTERACTIVE_WINDOW_VISIBLE_PROPERTY)); - return result.toBool(); + + return _qmlWindowProxy->readProperty(INTERACTIVE_WINDOW_VISIBLE_PROPERTY).toBool(); } glm::vec2 InteractiveWindow::getPosition() const { @@ -343,11 +345,7 @@ glm::vec2 InteractiveWindow::getPosition() const { return {}; } - QVariant result; - BLOCKING_INVOKE_METHOD(_qmlWindowProxy.get(), "readProperty", Q_RETURN_ARG(QVariant, result), - Q_ARG(QString, INTERACTIVE_WINDOW_POSITION_PROPERTY)); - - return toGlm(result.toPointF()); + return toGlm(_qmlWindowProxy->readProperty(INTERACTIVE_WINDOW_POSITION_PROPERTY).toPointF()); } void InteractiveWindow::setPosition(const glm::vec2& position) { @@ -363,10 +361,7 @@ glm::vec2 InteractiveWindow::getSize() const { return {}; } - QVariant result; - BLOCKING_INVOKE_METHOD(_qmlWindowProxy.get(), "readProperty", Q_RETURN_ARG(QVariant, result), - Q_ARG(QString, INTERACTIVE_WINDOW_SIZE_PROPERTY)); - return toGlm(result.toSize()); + return toGlm(_qmlWindowProxy->readProperty(INTERACTIVE_WINDOW_SIZE_PROPERTY).toSize()); } void InteractiveWindow::setSize(const glm::vec2& size) { @@ -382,10 +377,7 @@ QString InteractiveWindow::getTitle() const { return QString(); } - QVariant result; - BLOCKING_INVOKE_METHOD(_qmlWindowProxy.get(), "readProperty", Q_RETURN_ARG(QVariant, result), - Q_ARG(QString, TITLE_PROPERTY)); - return result.toString(); + return _qmlWindowProxy->readProperty(TITLE_PROPERTY).toString(); } void InteractiveWindow::setTitle(const QString& title) { @@ -399,10 +391,8 @@ int InteractiveWindow::getPresentationMode() const { if (!_qmlWindowProxy) { return Virtual; } - QVariant result; - BLOCKING_INVOKE_METHOD(_qmlWindowProxy.get(), "readProperty", Q_RETURN_ARG(QVariant, result), - Q_ARG(QString, PRESENTATION_MODE_PROPERTY)); - return result.toInt(); + + return _qmlWindowProxy->readProperty(PRESENTATION_MODE_PROPERTY).toInt(); } void InteractiveWindow::parentNativeWindowToMainWindow() {