summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-03-20 11:36:02 +0100
committerMarc Mutz <[email protected]>2025-03-21 07:05:13 +0100
commitd624454586bc040c381091f45ca43dcb43f7112c (patch)
tree7b836da9a5cdc5ae65d3afb6cba9fbf8fccc0963 /src
parent536cd1ce20a59e4daaf3a09c115f2dc5ad9cbf91 (diff)
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. Amends 0328e4297e339de8a2acd84979c667936f6fadf8. Coverity picked this up as a new issue following 53fb13456fffe8bfd192f9197c6d1703854b49a2, 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 <[email protected]> Reviewed-by: Axel Spoerl <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gui/platform/unix/qdbuslistener.cpp5
-rw-r--r--src/gui/platform/unix/qdbuslistener_p.h1
2 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/platform/unix/qdbuslistener.cpp b/src/gui/platform/unix/qdbuslistener.cpp
index d6a05cc17eb..213d190fa6b 100644
--- a/src/gui/platform/unix/qdbuslistener.cpp
+++ b/src/gui/platform/unix/qdbuslistener.cpp
@@ -219,8 +219,9 @@ std::optional<QDBusListener::ChangeSignal>
{
const DBusKey dkey(location, key);
std::optional<QDBusListener::ChangeSignal> ret;
- if (m_signalMap.contains(dkey))
- ret.emplace(m_signalMap.value(dkey));
+ const auto it = m_signalMap.find(dkey);
+ if (it != m_signalMap.cend())
+ ret.emplace(it.value());
return ret;
}
diff --git a/src/gui/platform/unix/qdbuslistener_p.h b/src/gui/platform/unix/qdbuslistener_p.h
index cadcab76c54..cde62266177 100644
--- a/src/gui/platform/unix/qdbuslistener_p.h
+++ b/src/gui/platform/unix/qdbuslistener_p.h
@@ -70,7 +70,6 @@ private:
Provider provider;
Setting setting;
ChangeSignal(Provider p, Setting s) : provider(p), setting(s) {}
- ChangeSignal() {}
};
QFlatMap <DBusKey, ChangeSignal> m_signalMap;