Use QFlatMap::operator[] when the reference value is needed

The QGtk3Json::save() function does not save the palettes properly. The
bug was occurring as the QFlatMap::value() method returns a copy of the
value stored in the object.

To fix this bug, the QFlatMap::operator[] operator is used as it returns
a reference to the value. Then the update happens on the original value
in the QFlatMap object.

Pick-to: 6.7 6.5
Change-Id: Ib6f9e350f5447027de4d0a8e6cb8a84012ea8990
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
(cherry picked from commit e17245505ea4ae2bdc05608114586bc5fa933d58)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
MohammadHossein Qanbari 2024-06-27 18:41:19 +02:00 committed by Qt Cherry-pick Bot
parent 2aaafce903
commit 88d8e35ccb

View File

@ -154,7 +154,7 @@ const QJsonDocument QGtk3Json::save(const QGtk3Storage::PaletteMap &map)
++brushIterator) {
const QPalette::ColorRole role = brushIterator.key().colorRole;
if (brushMaps.contains(role)) {
brushMaps.value(role).insert(brushIterator.key(), brushIterator.value());
brushMaps[role].insert(brushIterator.key(), brushIterator.value());
} else {
QGtk3Storage::BrushMap newMap;
newMap.insert(brushIterator.key(), brushIterator.value());