From 9d665ca5a509d3f39e8f3882b28b8706e2acb19f Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Wed, 31 Jul 2024 18:14:26 +0200 Subject: [PATCH] prevent event loop reentrance when handling ENCRYPT socket requests when receiving a shell integration socket command for ENCRYPT, a generic interface and generic code paths was used the assumption was that the listener socket would need (and remain) valid while hanlding teh request some code paths need to display error messages to the user via a QMessageBox the issue is that this will execute a Qt event loop that will handle the socket disconnection while the socket variable from the caller seems it will stay valid and alive prevent that by not using a blocking method invocation such that life time mishandling about the socket listener is not possible Signed-off-by: Matthieu Gallien --- src/gui/socketapi/socketapi.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp index b4b5a913a28ce..a3f306fb71cd5 100644 --- a/src/gui/socketapi/socketapi.cpp +++ b/src/gui/socketapi/socketapi.cpp @@ -444,6 +444,13 @@ void SocketApi::slotReadSocket() << "with argument:" << argument; socketApiJob->failure(QStringLiteral("command not found")); } + } else if (command.startsWith("ENCRYPT")) { + if (indexOfMethod != -1) { + ASSERT(thread() == QThread::currentThread()) + staticMetaObject.method(indexOfMethod) + .invoke(this, Qt::QueuedConnection, Q_ARG(QString, argument.toString()), + Q_ARG(SocketListener *, listener.data())); + } } else { if (indexOfMethod != -1) { // to ensure that listener is still valid we need to call it with Qt::DirectConnection