Fix QML warnings at shutdown

This commit is contained in:
David Rowe 2016-04-16 15:23:41 +12:00
parent 7b49552066
commit 8f6cfb72ea
7 changed files with 57 additions and 8 deletions

View file

@ -17,7 +17,7 @@ import "windows"
Window { Window {
id: root id: root
HifiConstants { id: hifi } HifiConstants { id: hifi }
anchors.centerIn: parent
objectName: "AddressBarDialog" objectName: "AddressBarDialog"
frame: HiddenFrame {} frame: HiddenFrame {}
@ -29,6 +29,19 @@ Window {
width: addressBarDialog.implicitWidth width: addressBarDialog.implicitWidth
height: addressBarDialog.implicitHeight 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 { AddressBarDialog {
id: addressBarDialog id: addressBarDialog
implicitWidth: backgroundImage.width implicitWidth: backgroundImage.width

View file

@ -3,10 +3,24 @@ import QtQuick 2.3
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
Item { Item {
anchors.fill: parent id: stats
anchors.leftMargin: 300 anchors.leftMargin: 300
objectName: "StatsItem" 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 { Hifi.Stats {
id: root id: root
objectName: "Stats" objectName: "Stats"

View file

@ -248,9 +248,15 @@ Fadable {
children: [ swallower, frame, pane, activator ] children: [ swallower, frame, pane, activator ]
Component.onCompleted: { raise(); setDefaultFocus(); } Component.onCompleted: {
Component.onDestruction: windowDestroyed(); window.parentChanged.connect(raise);
onParentChanged: raise(); raise();
setDefaultFocus();
}
Component.onDestruction: {
window.parentChanged.disconnect(raise); // Prevent warning on shutdown
windowDestroyed();
}
onVisibleChanged: { onVisibleChanged: {
if (!visible && destroyOnInvisible) { if (!visible && destroyOnInvisible) {

View file

@ -114,9 +114,14 @@ Fadable {
children: [ swallower, frame, content, activator ] children: [ swallower, frame, content, activator ]
Component.onCompleted: raise(); Component.onCompleted: {
Component.onDestruction: windowDestroyed(); window.parentChanged.connect(raise);
onParentChanged: raise(); raise();
}
Component.onDestruction: {
window.parentChanged.disconnect(raise); // Prevent warning on shutdown
windowDestroyed();
}
onVisibleChanged: { onVisibleChanged: {
if (!visible && destroyOnInvisible) { if (!visible && destroyOnInvisible) {

View file

@ -1150,6 +1150,9 @@ void Application::aboutToQuit() {
getActiveDisplayPlugin()->deactivate(); getActiveDisplayPlugin()->deactivate();
// Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown.
DependencyManager::get<OffscreenUi>()->hide("RunningScripts");
_aboutToQuit = true; _aboutToQuit = true;
cleanupBeforeQuit(); cleanupBeforeQuit();

View file

@ -143,6 +143,13 @@ void OffscreenUi::toggle(const QUrl& url, const QString& name, std::function<voi
} }
} }
void OffscreenUi::hide(const QString& name) {
QQuickItem* item = getRootItem()->findChild<QQuickItem*>(name);
if (item) {
item->setVisible(false);
}
}
class ModalDialogListener : public QObject { class ModalDialogListener : public QObject {
Q_OBJECT Q_OBJECT
friend class OffscreenUi; friend class OffscreenUi;

View file

@ -37,6 +37,7 @@ public:
virtual void create(QOpenGLContext* context) override; virtual void create(QOpenGLContext* context) override;
void createDesktop(const QUrl& url); void createDesktop(const QUrl& url);
void show(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); void show(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
void hide(const QString& name);
void toggle(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); void toggle(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
bool shouldSwallowShortcut(QEvent* event); bool shouldSwallowShortcut(QEvent* event);
bool navigationFocused(); bool navigationFocused();