summaryrefslogtreecommitdiff
path: root/src/controls/TreeView.qml
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-05-21 13:44:38 +0200
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-05-22 09:35:08 +0000
commit473410b99b362d0f39017d3390d5c44e513b8b8c (patch)
treeadb6990e1066dbad8434843f03ea698c62b3f4a4 /src/controls/TreeView.qml
parenta1ec337d062986402927494de46ad99c5f7ffc42 (diff)
downloadqtquickcontrols-473410b99b362d0f39017d3390d5c44e513b8b8c.tar.gz
TreeView: Check that indexes belong to the current model
And warn the user about it. We omit printing anything else in case we would be holding an invalid reference to some model. Internally, we assert if, despite the guards, we still get the wrong model indexes. Change-Id: I8e7451375d19c2aa406257a9b0193d59f69b0355 Task-number: QTBUG-46214 Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com> Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/controls/TreeView.qml')
-rw-r--r--src/controls/TreeView.qml14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/controls/TreeView.qml b/src/controls/TreeView.qml
index 08f0da4d..84c30edd 100644
--- a/src/controls/TreeView.qml
+++ b/src/controls/TreeView.qml
@@ -56,15 +56,25 @@ BasicTableView {
signal collapsed(var index)
function isExpanded(index) {
+ if (index.valid && index.model !== model) {
+ console.warn("TreeView.isExpanded: model and index mismatch")
+ return false
+ }
return modelAdaptor.isExpanded(index)
}
function collapse(index) {
- modelAdaptor.collapse(index)
+ if (index.valid && index.model !== model)
+ console.warn("TreeView.collapse: model and index mismatch")
+ else
+ modelAdaptor.collapse(index)
}
function expand(index) {
- modelAdaptor.expand(index)
+ if (index.valid && index.model !== model)
+ console.warn("TreeView.expand: model and index mismatch")
+ else
+ modelAdaptor.expand(index)
}
function indexAt(x, y) {