aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/qt_connection_util.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/qt_connection_util.h b/lib/qt_connection_util.h
index 2df2b186..c2bde8df 100644
--- a/lib/qt_connection_util.h
+++ b/lib/qt_connection_util.h
@@ -30,11 +30,16 @@ namespace QMatrixClient {
SenderT* sender, SignalT signal, ContextT* context,
std::function<bool(ArgTs...)> slot, Qt::ConnectionType connType)
{
+ // See https://bugreports.qt.io/browse/QTBUG-60339
+#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
+ auto pc = std::make_shared<QMetaObject::Connection>();
+#else
auto pc = std::make_unique<QMetaObject::Connection>();
+#endif
auto& c = *pc; // Resolve a reference before pc is moved to lambda
c = QObject::connect(sender, signal, context,
[pc=std::move(pc),slot] (ArgTs... args) {
- Q_ASSERT(*pc);
+ Q_ASSERT(*pc); // If it's been triggered, it should exist
if (slot(std::forward<ArgTs>(args)...))
QObject::disconnect(*pc);
}, connType);