From 8f6cfb72ea70f8f46e912e363ef3e4999402f65b Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 16 Apr 2016 15:23:41 +1200 Subject: [PATCH] Fix QML warnings at shutdown --- interface/resources/qml/AddressBarDialog.qml | 15 ++++++++++++++- interface/resources/qml/Stats.qml | 16 +++++++++++++++- interface/resources/qml/windows-uit/Window.qml | 12 +++++++++--- interface/resources/qml/windows/Window.qml | 11 ++++++++--- interface/src/Application.cpp | 3 +++ libraries/ui/src/OffscreenUi.cpp | 7 +++++++ libraries/ui/src/OffscreenUi.h | 1 + 7 files changed, 57 insertions(+), 8 deletions(-) diff --git a/interface/resources/qml/AddressBarDialog.qml b/interface/resources/qml/AddressBarDialog.qml index c3d795f0a3..c5712c11d2 100644 --- a/interface/resources/qml/AddressBarDialog.qml +++ b/interface/resources/qml/AddressBarDialog.qml @@ -17,7 +17,7 @@ import "windows" Window { id: root HifiConstants { id: hifi } - anchors.centerIn: parent + objectName: "AddressBarDialog" frame: HiddenFrame {} @@ -29,6 +29,19 @@ Window { width: addressBarDialog.implicitWidth height: addressBarDialog.implicitHeight + Component.onCompleted: { + root.parentChanged.connect(center); + center(); + } + Component.onDestruction: { + root.parentChanged.disconnect(center); + } + + function center() { + // Explicitly center in order to avoid warnings at shutdown + anchors.centerIn = parent; + } + AddressBarDialog { id: addressBarDialog implicitWidth: backgroundImage.width diff --git a/interface/resources/qml/Stats.qml b/interface/resources/qml/Stats.qml index e2dfae2a02..fe88899658 100644 --- a/interface/resources/qml/Stats.qml +++ b/interface/resources/qml/Stats.qml @@ -3,10 +3,24 @@ import QtQuick 2.3 import QtQuick.Controls 1.2 Item { - anchors.fill: parent + id: stats + anchors.leftMargin: 300 objectName: "StatsItem" + Component.onCompleted: { + stats.parentChanged.connect(fill); + fill(); + } + Component.onDestruction: { + stats.parentChanged.disconnect(fill); + } + + function fill() { + // Explicitly fill in order to avoid warnings at shutdown + anchors.fill = parent; + } + Hifi.Stats { id: root objectName: "Stats" diff --git a/interface/resources/qml/windows-uit/Window.qml b/interface/resources/qml/windows-uit/Window.qml index 32fc816173..0437e63615 100644 --- a/interface/resources/qml/windows-uit/Window.qml +++ b/interface/resources/qml/windows-uit/Window.qml @@ -248,9 +248,15 @@ Fadable { children: [ swallower, frame, pane, activator ] - Component.onCompleted: { raise(); setDefaultFocus(); } - Component.onDestruction: windowDestroyed(); - onParentChanged: raise(); + Component.onCompleted: { + window.parentChanged.connect(raise); + raise(); + setDefaultFocus(); + } + Component.onDestruction: { + window.parentChanged.disconnect(raise); // Prevent warning on shutdown + windowDestroyed(); + } onVisibleChanged: { if (!visible && destroyOnInvisible) { diff --git a/interface/resources/qml/windows/Window.qml b/interface/resources/qml/windows/Window.qml index 6088a7a0aa..06be0cd9e7 100644 --- a/interface/resources/qml/windows/Window.qml +++ b/interface/resources/qml/windows/Window.qml @@ -114,9 +114,14 @@ Fadable { children: [ swallower, frame, content, activator ] - Component.onCompleted: raise(); - Component.onDestruction: windowDestroyed(); - onParentChanged: raise(); + Component.onCompleted: { + window.parentChanged.connect(raise); + raise(); + } + Component.onDestruction: { + window.parentChanged.disconnect(raise); // Prevent warning on shutdown + windowDestroyed(); + } onVisibleChanged: { if (!visible && destroyOnInvisible) { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3a0b0998c5..dbb30a4582 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1150,6 +1150,9 @@ void Application::aboutToQuit() { getActiveDisplayPlugin()->deactivate(); + // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown. + DependencyManager::get()->hide("RunningScripts"); + _aboutToQuit = true; cleanupBeforeQuit(); diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 45413b6c35..0c1ad69d72 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -143,6 +143,13 @@ void OffscreenUi::toggle(const QUrl& url, const QString& name, std::functionfindChild(name); + if (item) { + item->setVisible(false); + } +} + class ModalDialogListener : public QObject { Q_OBJECT friend class OffscreenUi; diff --git a/libraries/ui/src/OffscreenUi.h b/libraries/ui/src/OffscreenUi.h index 0e87018c5c..5a16b49491 100644 --- a/libraries/ui/src/OffscreenUi.h +++ b/libraries/ui/src/OffscreenUi.h @@ -37,6 +37,7 @@ public: virtual void create(QOpenGLContext* context) override; void createDesktop(const QUrl& url); void show(const QUrl& url, const QString& name, std::function f = [](QQmlContext*, QObject*) {}); + void hide(const QString& name); void toggle(const QUrl& url, const QString& name, std::function f = [](QQmlContext*, QObject*) {}); bool shouldSwallowShortcut(QEvent* event); bool navigationFocused();