Commit f4e0183a authored by Alexander Saoutkin's avatar Alexander Saoutkin
Browse files

Fix lifetime of slot in KIO-MTP

Summary:
This slot was incorrectly made to last the lifetime of the slave. In fact, this
slot should only be live for the lifetime of the event loop (one I/O operation).

This can cause issues with the data being emitted for data from other IO
operations. By making it live in the lifetime of the local event loop this
scenario cannot occur as LIBMTP only allows one operation at a time.

Test Plan:
Via the use of KIOFuse (as this is where the bug was noticed).
Before: Opening a file for the first time worked. Subsequent opens would fail
due to garbage output After: Opening any number of files at any time works.

Reviewers: akrutzler, dfaure, elvisangelaccio

Subscribers: kde-frameworks-devel, kfm-devel, fvogt

Tags: #dolphin, #frameworks

Differential Revision: https://phabricator.kde.org/D28520
parent f40191a1
......@@ -398,7 +398,7 @@ void MTPSlave::get(const QUrl &url)
}
QEventLoop loop;
connect(storage, &KMTPStorageInterface::dataReady, this, [this] (const QByteArray &data) {
connect(storage, &KMTPStorageInterface::dataReady, &loop, [this] (const QByteArray &data) {
MTPSlave::data(data);
});
connect(storage, &KMTPStorageInterface::copyFinished, &loop, &QEventLoop::exit);
......@@ -861,7 +861,7 @@ void MTPSlave::fileSystemFreeSpace(const QUrl &url)
int MTPSlave::waitForCopyOperation(const KMTPStorageInterface *storage)
{
QEventLoop loop;
connect(storage, &KMTPStorageInterface::copyProgress, this, [this] (qulonglong sent, qulonglong total) {
connect(storage, &KMTPStorageInterface::copyProgress, &loop, [this] (qulonglong sent, qulonglong total) {
Q_UNUSED(total)
processedSize(sent);
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment