From ff6f7233e499d8a021501586fe4c5580000a730b Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Thu, 21 Jan 2021 17:38:55 -0800 Subject: [PATCH] I'm a big dumb idiot --- .../scripting/WindowScriptingInterface.cpp | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 14a0d04023..98335e5d3a 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -199,9 +199,9 @@ void WindowScriptingInterface::setInterstitialModeEnabled(bool enableInterstitia DependencyManager::get()->getDomainHandler().setInterstitialModeEnabled(enableInterstitialMode); } -bool WindowScriptingInterface::isPointOnDesktopWindow(QVariant point) { - auto offscreenUi = DependencyManager::get(); - return offscreenUi->isPointOnDesktopWindow(point); +bool WindowScriptingInterface::isPointOnDesktopWindow(QVariant point) { + auto offscreenUI = DependencyManager::get(); + return offscreenUI ? offscreenUI->isPointOnDesktopWindow(point) : false; } /// Makes sure that the reticle is visible, use this in blocking forms that require a reticle and @@ -553,12 +553,14 @@ int WindowScriptingInterface::openMessageBox(QString title, QString text, int bu * @typedef {number} Window.MessageBoxButton */ int WindowScriptingInterface::createMessageBox(QString title, QString text, int buttons, int defaultButton) { - auto messageBox = DependencyManager::get()->createMessageBox(OffscreenUi::ICON_INFORMATION, title, text, - static_cast>(buttons), static_cast(defaultButton)); - connect(messageBox, SIGNAL(selected(int)), this, SLOT(onMessageBoxSelected(int))); + if (auto offscreenUI = DependencyManager::get()) { + auto messageBox = offscreenUI->createMessageBox(OffscreenUi::ICON_INFORMATION, title, text, + static_cast>(buttons), static_cast(defaultButton)); + connect(messageBox, SIGNAL(selected(int)), this, SLOT(onMessageBoxSelected(int))); - _lastMessageBoxID += 1; - _messageBoxes.insert(_lastMessageBoxID, messageBox); + _lastMessageBoxID += 1; + _messageBoxes.insert(_lastMessageBoxID, messageBox); + } return _lastMessageBoxID; } @@ -646,13 +648,17 @@ void WindowScriptingInterface::setActiveDisplayPlugin(int index) { } void WindowScriptingInterface::openWebBrowser(const QString& url) { + auto offscreenUI = DependencyManager::get(); + if (!offscreenUI) { + return; + } + if (QThread::currentThread() != thread()) { QMetaObject::invokeMethod(this, "openWebBrowser", Q_ARG(const QString&, url)); return; } - auto offscreenUi = DependencyManager::get(); - offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { + offscreenUI->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { if (!url.isEmpty()) { newObject->setProperty("url", url); }