From 6403d3afd868bbdffddc52d8be0a56081637adf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Wed, 16 Sep 2020 10:43:52 +0200 Subject: Use less pointers in tst_loadsignals Make QWebEngineView a member of tst_LoadSignals. Also stop recreating it for every test. Task-number: QTBUG-65223 Change-Id: I2ed7c12559e56e23302813eb6f33c1e26a9d8748 Reviewed-by: Kirill Burtsev --- tests/auto/widgets/util.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/auto/widgets/util.h') diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h index cb58f4243..af0b9bf6f 100644 --- a/tests/auto/widgets/util.h +++ b/tests/auto/widgets/util.h @@ -42,6 +42,17 @@ #define TESTS_SOURCE_DIR "" #endif +// Disconnect signal on destruction. +class ScopedConnection +{ +public: + ScopedConnection(QMetaObject::Connection connection) : m_connection(std::move(connection)) { } + ~ScopedConnection() { QObject::disconnect(m_connection); } + +private: + QMetaObject::Connection m_connection; +}; + /** * Just like QSignalSpy but facilitates sync and async * signal emission. For example if you want to verify that -- cgit v1.2.3