From 1593c1185aa0701d6bdf2754570cfbeebc62a45b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 14 Nov 2018 12:28:01 -0800 Subject: [PATCH] revert PR-14238 "TypeError: Cannot read property 'buttons'" until we can adjust it. --- interface/resources/qml/hifi/Desktop.qml | 4 ++-- interface/resources/qml/hifi/tablet/TabletHome.qml | 4 ++-- libraries/qml/src/qml/OffscreenSurface.cpp | 8 ++------ libraries/qml/src/qml/impl/SharedObject.cpp | 12 +----------- libraries/qml/src/qml/impl/SharedObject.h | 4 +--- 5 files changed, 8 insertions(+), 24 deletions(-) diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index 354c8095a0..f57c612b98 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -70,8 +70,8 @@ OriginalDesktop.Desktop { anchors.horizontalCenter: settings.constrainToolbarToCenterX ? desktop.horizontalCenter : undefined; // Literal 50 is overwritten by settings from previous session, and sysToolbar.x comes from settings when not constrained. x: sysToolbar.x - buttonModel: tablet ? tablet.buttons : null; - shown: tablet ? tablet.toolbarMode : false; + buttonModel: tablet.buttons; + shown: tablet.toolbarMode; } Settings { diff --git a/interface/resources/qml/hifi/tablet/TabletHome.qml b/interface/resources/qml/hifi/tablet/TabletHome.qml index cbfb3c1337..f1f54e8419 100644 --- a/interface/resources/qml/hifi/tablet/TabletHome.qml +++ b/interface/resources/qml/hifi/tablet/TabletHome.qml @@ -115,9 +115,9 @@ Item { property int previousIndex: -1 Repeater { id: pageRepeater - model: tabletProxy != null ? Math.ceil(tabletProxy.buttons.rowCount() / TabletEnums.ButtonsOnPage) : 0 + model: Math.ceil(tabletProxy.buttons.rowCount() / TabletEnums.ButtonsOnPage) onItemAdded: { - item.proxyModel.sourceModel = tabletProxy != null ? tabletProxy.buttons : null; + item.proxyModel.sourceModel = tabletProxy.buttons; item.proxyModel.pageIndex = index; } diff --git a/libraries/qml/src/qml/OffscreenSurface.cpp b/libraries/qml/src/qml/OffscreenSurface.cpp index 7edd4e481c..91532534e3 100644 --- a/libraries/qml/src/qml/OffscreenSurface.cpp +++ b/libraries/qml/src/qml/OffscreenSurface.cpp @@ -387,12 +387,8 @@ void OffscreenSurface::finishQmlLoad(QQmlComponent* qmlComponent, if (!parent) { parent = getRootItem(); } - // manually control children items lifetime - QQmlEngine::setObjectOwnership(newObject, QQmlEngine::CppOwnership); - - // add object to the manual deletion list - _sharedObject->addToDeletionList(newObject); - + // Allow child windows to be destroyed from JS + QQmlEngine::setObjectOwnership(newObject, QQmlEngine::JavaScriptOwnership); newObject->setParent(parent); newItem->setParentItem(parent); } else { diff --git a/libraries/qml/src/qml/impl/SharedObject.cpp b/libraries/qml/src/qml/impl/SharedObject.cpp index 1f41fefb02..259defdb48 100644 --- a/libraries/qml/src/qml/impl/SharedObject.cpp +++ b/libraries/qml/src/qml/impl/SharedObject.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include @@ -82,6 +81,7 @@ SharedObject::SharedObject() { SharedObject::~SharedObject() { // After destroy returns, the rendering thread should be gone destroy(); + // _renderTimer is created with `this` as the parent, so need no explicit destruction #ifndef DISABLE_QML // Destroy the event hand @@ -96,11 +96,6 @@ SharedObject::~SharedObject() { } #endif - // already deleted objects will be reset to null by QPointer so it should be safe just iterate here - for (auto qmlObject : _deletionList) { - delete qmlObject; - } - if (_rootItem) { delete _rootItem; _rootItem = nullptr; @@ -417,11 +412,6 @@ bool SharedObject::fetchTexture(TextureAndFence& textureAndFence) { return true; } -void hifi::qml::impl::SharedObject::addToDeletionList(QObject * object) -{ - _deletionList.append(QPointer(object)); -} - void SharedObject::setProxyWindow(QWindow* window) { #ifndef DISABLE_QML _proxyWindow = window; diff --git a/libraries/qml/src/qml/impl/SharedObject.h b/libraries/qml/src/qml/impl/SharedObject.h index ce9fcd46d2..002679c44d 100644 --- a/libraries/qml/src/qml/impl/SharedObject.h +++ b/libraries/qml/src/qml/impl/SharedObject.h @@ -66,7 +66,7 @@ public: void resume(); bool isPaused() const; bool fetchTexture(TextureAndFence& textureAndFence); - void addToDeletionList(QObject* object); + private: bool event(QEvent* e) override; @@ -91,8 +91,6 @@ private: void onAboutToQuit(); void updateTextureAndFence(const TextureAndFence& newTextureAndFence); - QList> _deletionList; - // Texture management TextureAndFence _latestTextureAndFence{ 0, 0 }; QQuickItem* _item{ nullptr };