From b3b75c37e2d3ef313031ceba8063feeccb0583ec Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Thu, 10 Jun 2021 15:36:26 +0200 Subject: [PATCH] qt: Flush output after write for QProcess output * lang/qt/src/dataprovider.cpp (QIODeviceDataProvider::write): Call waitForBytesWritten. -- The problem here is that QProcess writes into an internal buffer which is written to stdin of the process triggered by a signal/slot connection. That connection is broken when we move the QProcess into our GPGME thread and only restablished when our Job is finished. This caused Kleopatra to basically keep everything when decrypting a large archive in memory and only write it out to the unpack process once the decryption was finished. GnuPG-Bug-Id: T5475 --- lang/qt/src/dataprovider.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lang/qt/src/dataprovider.cpp b/lang/qt/src/dataprovider.cpp index a025a03e..820ccbb3 100644 --- a/lang/qt/src/dataprovider.cpp +++ b/lang/qt/src/dataprovider.cpp @@ -248,7 +248,17 @@ ssize_t QIODeviceDataProvider::write(const void *buffer, size_t bufSize) return -1; } - return mIO->write(static_cast(buffer), bufSize); + ssize_t ret = mIO->write(static_cast(buffer), bufSize); + if (mHaveQProcess) { + /* XXX: With at least Qt 5.12 we have the problem that the acutal write + * would be triggered by an event / slot. So as we have moved the io + * device to our thread this is never triggered until the job is finished + * calling waitForBytesWritten internally triggers a _q_canWrite which will + * actually write. This is what we want as we want to stream and not to + * buffer endlessly. */ + qobject_cast(mIO.get())->waitForBytesWritten(0); + } + return ret; } off_t QIODeviceDataProvider::seek(off_t offset, int whence)