From 80ba7e03afe18cc44715f7cf9a038bedff01f328 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Thu, 15 Nov 2018 00:13:59 +0100 Subject: QQuickTreeModelAdaptor1: fix out of range issue in selectionForRowRange If the index of the "to" row is invalid and the one from the "from" row is good, then the method will try to access an invalid index. This patch fixes that by ensuring that if the "to" row is invalid (when, for example, the mouse cursor goes out of the view while multiple selection is activated), the "to" index used stays valid. [ChangeLog][Controls][QQuickTreeModelAdaptor1] Fixed an issue where an invalid access was done if either extended or multiple selection was in use and the mouse went out of the view on top of the model. Fixes: QTBUG-71789 Change-Id: I32d8a20ee9ffc1c40584f17c27ceb06d48b81ff0 Reviewed-by: Alex Blasche --- src/controls/Private/qquicktreemodeladaptor.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/controls/Private/qquicktreemodeladaptor.cpp') diff --git a/src/controls/Private/qquicktreemodeladaptor.cpp b/src/controls/Private/qquicktreemodeladaptor.cpp index 495abc9c..d2ed42b2 100644 --- a/src/controls/Private/qquicktreemodeladaptor.cpp +++ b/src/controls/Private/qquicktreemodeladaptor.cpp @@ -283,6 +283,8 @@ QItemSelection QQuickTreeModelAdaptor1::selectionForRowRange(const QModelIndex return QItemSelection(); return QItemSelection(toIndex, toIndex); } + + to = qMax(to, 0); if (from > to) qSwap(from, to); -- cgit v1.2.1