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 Aug 8, 2024
1 parent 7fc2378 commit 585c4d5
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 @@ -428,6 +428,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 585c4d5

Please sign in to comment.