mirror of https://github.com/qt/qtbase.git
QDBusListener: remove ChangeSignal's defaut ctor
Coverity complained that the default ctor didn't initialize its two members. This is true, and it even remains true if the user of the type explicitly asks for value-initialization (ChangeSignal s = {}) as opposed to default-construction (ChangeSignal s;). Remove the default ctor as the minimally-possible fix. It was only needed because of a call to QFlatMap::value(1-arg), which, incidentally, constitutes a double-lookup, because it is following a contains() call. Replacing that combo with find() and it.value() avoids the double-lookup and removes the need for the type to be default-constructible. Amends0328e4297e
. Coverity picked this up as a new issue following53fb13456f
, so there probably is another CID for this for the same code in the old location, but my Coverity search-foo is insufficient to find the corresponding CID, without undue effort, so I didn't try. Coverity-Id: 478089 Pick-to: 6.9 6.8 6.5 Change-Id: I912bf2af343b98fe62faf2d4bf8a6d1f385593e8 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
536cd1ce20
commit
d624454586
|
@ -219,8 +219,9 @@ std::optional<QDBusListener::ChangeSignal>
|
||||||
{
|
{
|
||||||
const DBusKey dkey(location, key);
|
const DBusKey dkey(location, key);
|
||||||
std::optional<QDBusListener::ChangeSignal> ret;
|
std::optional<QDBusListener::ChangeSignal> ret;
|
||||||
if (m_signalMap.contains(dkey))
|
const auto it = m_signalMap.find(dkey);
|
||||||
ret.emplace(m_signalMap.value(dkey));
|
if (it != m_signalMap.cend())
|
||||||
|
ret.emplace(it.value());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,6 @@ private:
|
||||||
Provider provider;
|
Provider provider;
|
||||||
Setting setting;
|
Setting setting;
|
||||||
ChangeSignal(Provider p, Setting s) : provider(p), setting(s) {}
|
ChangeSignal(Provider p, Setting s) : provider(p), setting(s) {}
|
||||||
ChangeSignal() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QFlatMap <DBusKey, ChangeSignal> m_signalMap;
|
QFlatMap <DBusKey, ChangeSignal> m_signalMap;
|
||||||
|
|
Loading…
Reference in New Issue