diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2021-07-07 14:51:36 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-08 14:33:53 +0000 |
commit | dc48e368fe6973d4fd6170735676aff9085c6105 (patch) | |
tree | 31d76caaef81965ee5cd738356278becc1d8787c /src | |
parent | 4030fb42924d1e328d733e4a5ee975ffe3fd5aa1 (diff) |
QMultiHash::find - prevent detaching shared null
Do not detach when find(key, value) is called on an empty QMultiHash.
As a drive-by: fix return value for QMultiHash::remove() in case of
empty QMultiHash.
Task-number: QTBUG-91736
Change-Id: I1e32f359e7ee9ce8403dae79d02e0b88a20ec4a5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 82499f81478032911d8f788aa28e8d780b31c973)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qhash.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 1a793e6163..bfa2da6dbd 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -1782,7 +1782,7 @@ public: qsizetype remove(const Key &key, const T &value) { if (isEmpty()) // prevents detaching shared null - return false; + return 0; detach(); auto it = d->find(key); @@ -1844,6 +1844,8 @@ public: iterator find(const Key &key, const T &value) { + if (isEmpty()) + return end(); detach(); auto it = constFind(key, value); return iterator(it.i, it.e); |