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 {
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

View file

@ -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"

View file

@ -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) {

View file

@ -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) {

View file

@ -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<OffscreenUi>()->hide("RunningScripts");
_aboutToQuit = true;
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 {
Q_OBJECT
friend class OffscreenUi;

View file

@ -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<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*) {});
bool shouldSwallowShortcut(QEvent* event);
bool navigationFocused();