Skip to content

Commit

Permalink
prevent event loop reentrance when handling ENCRYPT socket requests
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mgallien committed Jul 31, 2024
1 parent da1a205 commit 9d665ca
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/gui/socketapi/socketapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9d665ca

Please sign in to comment.