Merge pull request #14238 from ElderOrb/FB19400

FB19400 during shutdown -- TypeError: Cannot read property 'buttons' …
This commit is contained in:
John Conklin II 2018-11-13 15:07:21 -08:00 committed by GitHub
commit 79e67ad45f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 8 deletions

View file

@ -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.buttons;
shown: tablet.toolbarMode;
buttonModel: tablet ? tablet.buttons : null;
shown: tablet ? tablet.toolbarMode : false;
}
Settings {

View file

@ -115,9 +115,9 @@ Item {
property int previousIndex: -1
Repeater {
id: pageRepeater
model: Math.ceil(tabletProxy.buttons.rowCount() / TabletEnums.ButtonsOnPage)
model: tabletProxy != null ? Math.ceil(tabletProxy.buttons.rowCount() / TabletEnums.ButtonsOnPage) : 0
onItemAdded: {
item.proxyModel.sourceModel = tabletProxy.buttons;
item.proxyModel.sourceModel = tabletProxy != null ? tabletProxy.buttons : null;
item.proxyModel.pageIndex = index;
}

View file

@ -387,8 +387,12 @@ void OffscreenSurface::finishQmlLoad(QQmlComponent* qmlComponent,
if (!parent) {
parent = getRootItem();
}
// Allow child windows to be destroyed from JS
QQmlEngine::setObjectOwnership(newObject, QQmlEngine::JavaScriptOwnership);
// manually control children items lifetime
QQmlEngine::setObjectOwnership(newObject, QQmlEngine::CppOwnership);
// add object to the manual deletion list
_sharedObject->addToDeletionList(newObject);
newObject->setParent(parent);
newItem->setParentItem(parent);
} else {

View file

@ -15,6 +15,7 @@
#include <QtQml/QQmlEngine>
#include <QtGui/QOpenGLContext>
#include <QPointer>
#include <NumericalConstants.h>
#include <shared/NsightHelpers.h>
@ -81,7 +82,6 @@ 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,6 +96,11 @@ 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;
@ -412,6 +417,11 @@ bool SharedObject::fetchTexture(TextureAndFence& textureAndFence) {
return true;
}
void hifi::qml::impl::SharedObject::addToDeletionList(QObject * object)
{
_deletionList.append(QPointer<QObject>(object));
}
void SharedObject::setProxyWindow(QWindow* window) {
#ifndef DISABLE_QML
_proxyWindow = window;

View file

@ -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,6 +91,8 @@ private:
void onAboutToQuit();
void updateTextureAndFence(const TextureAndFence& newTextureAndFence);
QList<QPointer<QObject>> _deletionList;
// Texture management
TextureAndFence _latestTextureAndFence{ 0, 0 };
QQuickItem* _item{ nullptr };