From c85a8d3647c4487c0d529744daf9e4f325b3b289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Tue, 21 Feb 2023 20:52:42 +0100 Subject: [PATCH] fix(StatusQ/Utils): Fix ModelChangeTracker and ModelUtils to handle properly --- ui/StatusQ/src/StatusQ/Core/Utils/ModelChangeTracker.qml | 4 +++- ui/StatusQ/src/StatusQ/Core/Utils/ModelUtils.qml | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ui/StatusQ/src/StatusQ/Core/Utils/ModelChangeTracker.qml b/ui/StatusQ/src/StatusQ/Core/Utils/ModelChangeTracker.qml index fa32aae2ec..9a174f1dcc 100644 --- a/ui/StatusQ/src/StatusQ/Core/Utils/ModelChangeTracker.qml +++ b/ui/StatusQ/src/StatusQ/Core/Utils/ModelChangeTracker.qml @@ -1,7 +1,7 @@ import QtQml 2.14 QtObject { - property alias model: d.target + property var model readonly property alias revision: d.revision @@ -12,6 +12,8 @@ QtObject { readonly property Connections _d: Connections { id: d + target: model ?? null + property int revision: 0 function onRowsInserted() { diff --git a/ui/StatusQ/src/StatusQ/Core/Utils/ModelUtils.qml b/ui/StatusQ/src/StatusQ/Core/Utils/ModelUtils.qml index 647f4ace9d..b3d3e97e41 100644 --- a/ui/StatusQ/src/StatusQ/Core/Utils/ModelUtils.qml +++ b/ui/StatusQ/src/StatusQ/Core/Utils/ModelUtils.qml @@ -54,8 +54,8 @@ QtObject { if (modelA === modelB) return true - const countA = modelA === null ? 0 : modelA.rowCount() - const countB = modelB === null ? 0 : modelB.rowCount() + const countA = !!modelA ? modelA.rowCount() : 0 + const countB = !!modelB ? modelB.rowCount() : 0 if (countA !== countB) return false @@ -78,8 +78,8 @@ QtObject { if (modelA === modelB) return true - const countA = modelA === null ? 0 : modelA.rowCount() - const countB = modelB === null ? 0 : modelB.rowCount() + const countA = !!modelA ? modelA.rowCount() : 0 + const countB = !!modelB ? modelB.rowCount() : 0 if (countA !== countB) return false