From 0725622f5571800a707762bdfb02258f88f2d9d9 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sat, 2 Jul 2022 13:15:10 +0200 Subject: [PATCH] Fix a potential crash when destroying ProxyModels --- libnymea-app/thingsproxy.cpp | 6 ++++++ nymea-app/ui/MainPage.qml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libnymea-app/thingsproxy.cpp b/libnymea-app/thingsproxy.cpp index aad90434..bbec32f0 100644 --- a/libnymea-app/thingsproxy.cpp +++ b/libnymea-app/thingsproxy.cpp @@ -565,6 +565,12 @@ bool ThingsProxy::lessThan(const QModelIndex &left, const QModelIndex &right) co leftThing = m_engine->thingManager()->things()->get(left.row()); rightThing = m_engine->thingManager()->things()->get(right.row()); } + if (!leftThing || !rightThing) { + // This should never happen, but apparently some very rare stack traces indicate it does happen. Bug in Qt? + qCWarning(dcThingManager()) << "Thing not found in source model!" << leftThing << rightThing << m_parentProxy << m_parentProxy->rowCount() << left << right; + Q_ASSERT(false); + return false; + } State *leftState = leftThing->stateByName(m_sortStateName); State *rightState = rightThing->stateByName(m_sortStateName); QVariant leftStateValue = leftState ? leftState->value() : 0; diff --git a/nymea-app/ui/MainPage.qml b/nymea-app/ui/MainPage.qml index ee5f5d42..5ab9b984 100644 --- a/nymea-app/ui/MainPage.qml +++ b/nymea-app/ui/MainPage.qml @@ -254,7 +254,7 @@ Page { clip: true source: "mainviews/" + model.source + ".qml" // visible: SwipeView.isCurrentItem - active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem +// active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem Binding { target: mainViewLoader.item