History

I'm a big dumb idiot

HifiExperiments committed 5 years ago

Commit ff6f7231 parent 2667af31 file · +16 −10Browse files

Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 1 file). Show all

Unified · Split

interface/src/scripting/WindowScriptingInterface.cpp+16−10
@@ -199,9 +199,9 @@ void WindowScriptingInterface::setInterstitialModeEnabled(bool enableInterstitia · 198 unmodified lines
199199 DependencyManager::get<NodeList>()->getDomainHandler().setInterstitialModeEnabled(enableInterstitialMode);
200200 }
201201
202−bool WindowScriptingInterface::isPointOnDesktopWindow(QVariant point) {
203− auto offscreenUi = DependencyManager::get<OffscreenUi>();
204− return offscreenUi->isPointOnDesktopWindow(point);
202+bool WindowScriptingInterface::isPointOnDesktopWindow(QVariant point) {
203+ auto offscreenUI = DependencyManager::get<OffscreenUi>();
204+ return offscreenUI ? offscreenUI->isPointOnDesktopWindow(point) : false;
205205 }
206206
207207 /// 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 · 345 unmodified lines
553553 * @typedef {number} Window.MessageBoxButton
554554 */
555555 int WindowScriptingInterface::createMessageBox(QString title, QString text, int buttons, int defaultButton) {
556− auto messageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION, title, text,
557− static_cast<QFlags<QMessageBox::StandardButton>>(buttons), static_cast<QMessageBox::StandardButton>(defaultButton));
558− connect(messageBox, SIGNAL(selected(int)), this, SLOT(onMessageBoxSelected(int)));
556+ if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) {
557+ auto messageBox = offscreenUI->createMessageBox(OffscreenUi::ICON_INFORMATION, title, text,
558+ static_cast<QFlags<QMessageBox::StandardButton>>(buttons), static_cast<QMessageBox::StandardButton>(defaultButton));
559+ connect(messageBox, SIGNAL(selected(int)), this, SLOT(onMessageBoxSelected(int)));
559560
560− _lastMessageBoxID += 1;
561− _messageBoxes.insert(_lastMessageBoxID, messageBox);
561+ _lastMessageBoxID += 1;
562+ _messageBoxes.insert(_lastMessageBoxID, messageBox);
563+ }
562564
563565 return _lastMessageBoxID;
564566 }
@@ -646,13 +648,17 @@ void WindowScriptingInterface::setActiveDisplayPlugin(int index) { · 81 unmodified lines
646648 }
647649
648650 void WindowScriptingInterface::openWebBrowser(const QString& url) {
651+ auto offscreenUI = DependencyManager::get<OffscreenUi>();
652+ if (!offscreenUI) {
653+ return;
654+ }
655+
649656 if (QThread::currentThread() != thread()) {
650657 QMetaObject::invokeMethod(this, "openWebBrowser", Q_ARG(const QString&, url));
651658 return;
652659 }
653660
654− auto offscreenUi = DependencyManager::get<OffscreenUi>();
655− offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
661+ offscreenUI->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
656662 if (!url.isEmpty()) {
657663 newObject->setProperty("url", url);
658664 }