FB19400 during shutdown -- TypeError: Cannot read property 'buttons' of null

note: change also resolve a lot of other shutdown errors from QML (related to null parent)
This commit is contained in:
Alexander Ivash 2018-10-19 02:53:15 +03:00
parent 4ef2ad041b
commit 5d8a253785
5 changed files with 19 additions and 7 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) : null
onItemAdded: {
item.proxyModel.sourceModel = tabletProxy.buttons;
item.proxyModel.sourceModel = tabletProxy != null ? tabletProxy.buttons : null;
item.proxyModel.pageIndex = index;
}

View file

@ -387,8 +387,16 @@ 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);
// some objects we are going to delete might be already deleted (children of parent we already deleted) so use QPointer to track lifetime
QPointer<QObject> trackedObject(newObject);
connect(_sharedObject, &SharedObject::onBeforeDestroyed, [trackedObject]() {
if (trackedObject) {
delete trackedObject.data();
}
});
newObject->setParent(parent);
newItem->setParentItem(parent);
} else {

View file

@ -79,9 +79,11 @@ SharedObject::SharedObject() {
SharedObject::~SharedObject() {
emit onBeforeDestroyed();
// 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

View file

@ -67,6 +67,8 @@ public:
bool isPaused() const;
bool fetchTexture(TextureAndFence& textureAndFence);
signals:
void onBeforeDestroyed();
private:
bool event(QEvent* e) override;