summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElias Steurer <i@kelteseth.net>2022-07-01 12:06:47 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-07-05 14:30:05 +0000
commit636173526af21971224b22282f167ff7ef724fa3 (patch)
treecd436551467ffc68d215dbfa2b6907b07acb2ef5
parent98c091a099804fca76c271505a5f3d92433d8f7a (diff)
Fix race condition when accessing invalid index
This can sometimes happen when clicking fast on different items in debug mode. This this is a fix by Roman Putintsev. [ChangeLog][QtRemoteObjects][ModelReplica] Fix race condition when accessing invalid index Fixes: QTBUG-74124 Change-Id: Ice95b4f91b50173ce804f3d664e9b12a4c74e1ce Reviewed-by: Brett Stottlemyer <bstottle@ford.com> (cherry picked from commit e96d2a9907adfefb6318d3085c55b8cfb6e44638) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/remoteobjects/qremoteobjectabstractitemmodelreplica_p.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/remoteobjects/qremoteobjectabstractitemmodelreplica_p.h b/src/remoteobjects/qremoteobjectabstractitemmodelreplica_p.h
index 57f368a..ceb3924 100644
--- a/src/remoteobjects/qremoteobjectabstractitemmodelreplica_p.h
+++ b/src/remoteobjects/qremoteobjectabstractitemmodelreplica_p.h
@@ -442,7 +442,10 @@ public:
return cacheData(toQModelIndex(index, q));
}
inline CacheData* createCacheData(const QtPrivate::IndexList &index) const {
- auto modelIndex = toQModelIndex(index, q);
+ bool ok = false;
+ auto modelIndex = toQModelIndex(index, q, &ok);
+ if (!ok)
+ return nullptr;
cacheData(modelIndex.parent())->ensureChildren(modelIndex.row() , modelIndex.row());
return cacheData(modelIndex);
}