summaryrefslogtreecommitdiffstats
path: root/src/testlib/qsignalspy.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2024-03-21 18:18:30 +0100
committerMarc Mutz <marc.mutz@qt.io>2024-04-24 22:34:14 +0200
commit46ad7fe966f6c191ff2123e95c3b6373f7b24287 (patch)
tree72c80b5e08595cae0da45eb0b89fabd9c12809e6 /src/testlib/qsignalspy.h
parent951bf6e3ec7c518dfc6b672cd1f99bcb5a347084 (diff)
QSignalSpy: make args member const
This means it's implicitly thread-safe now and we don't need to protect accesses to it with the mutex. Task-number: QTBUG-123544 Change-Id: I9f826003dca6fb81e7a75e283482c81ecff09be0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'src/testlib/qsignalspy.h')
-rw-r--r--src/testlib/qsignalspy.h12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/testlib/qsignalspy.h b/src/testlib/qsignalspy.h
index ccde13820a..5f52c1dcdf 100644
--- a/src/testlib/qsignalspy.h
+++ b/src/testlib/qsignalspy.h
@@ -12,8 +12,6 @@
#include <QtCore/qvariant.h>
#include <QtCore/qmutex.h>
-#include <mutex>
-
QT_BEGIN_NAMESPACE
@@ -65,15 +63,11 @@ public:
private:
explicit QSignalSpy(ObjectSignal os)
+ : args(os.obj ? makeArgs(os.sig, os.obj) : QList<int>{})
{
if (!os.obj)
return;
- auto tmp = makeArgs(os.sig, os.obj);
- {
- const auto lock = std::scoped_lock(m_mutex);
- args = std::move(tmp);
- }
if (!connectToSignal(os.obj, os.sig.methodIndex()))
return;
@@ -92,11 +86,11 @@ private:
// the full, normalized signal name
QByteArray sig;
// holds the QMetaType types for the argument list of the signal
- QList<int> args;
+ const QList<int> args;
QTestEventLoop m_loop;
bool m_waiting = false;
- QMutex m_mutex; // protects m_waiting, args and the QList base class, between appendArgs() and wait()
+ QMutex m_mutex; // protects m_waiting and the QList base class, between appendArgs() and wait()
};
QT_END_NAMESPACE