diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-07-03 01:58:26 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-08-06 19:15:39 +0200 |
commit | 4fc539bd846f08c5e448810e263f3850593b8dc2 (patch) | |
tree | 29f2ce5a0b609a389b9fc4935560a15a94e20ec3 /src/corelib | |
parent | 14090760a87f23509b7bb5ad846537c766cb44a5 (diff) |
QMap: fix insert() rvalue overloads
Receiving an rvalue still requires to check whether the parameter
is detached, otherwise we can't steal its backing std::map.
Change-Id: Ie88dbf39fd777112ad7bb20a46d5c2d65be8eb3d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qmap.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 2a87912c4a..9db8981bf5 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -655,6 +655,12 @@ public: if (!map.d || map.d->m.empty()) return; + if (map.d.isShared()) { + // fall back to a regular copy + insert(map); + return; + } + detach(); #ifdef __cpp_lib_node_extract @@ -1292,6 +1298,12 @@ public: if (!map.d || map.d->m.empty()) return; + if (map.d.isShared()) { + // fall back to a regular copy + insert(map); + return; + } + detach(); #ifdef __cpp_lib_node_extract |