[SocketApi] Ensure listener still exists
authorHannah von Reth <hannah.vonreth@owncloud.com>
Wed, 18 Mar 2020 15:07:50 +0000 (16:07 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:08 +0000 (10:59 +0100)
src/gui/socketapi.cpp

index f64e44d33799f98196696556244e2ffb6e19b670..e453271bf0b737dbca7dfde15be669941b1fda9f 100644 (file)
@@ -388,8 +388,10 @@ void SocketApi::slotReadSocket()
             }
         } else {
             if (indexOfMethod != -1) {
+                // to ensure that listener is still valid we need to call it with Qt::DirectConnection
+                ASSERT(thread() == QThread::currentThread())
                 staticMetaObject.method(indexOfMethod)
-                    .invoke(this, Qt::QueuedConnection, Q_ARG(QString, argument),
+                    .invoke(this, Qt::DirectConnection, Q_ARG(QString, argument),
                             Q_ARG(SocketListener *, listener));
             } else {
                 qCWarning(lcSocketApi) << "The command is not supported by this version of the client:" << command << "with argument:" << argument;