KCompressionDevice: propagate errors from QIODevice::close() BUG: 397545
ClosedPublic

Authored by dfaure on Aug 17 2018, 11:06 PM.

Details

Summary

QFile::close() doesn't return a value, but sets an error string instead,
we need to check for that and set it in KCompressionDevice so apps can check for that in turn.

Test Plan

Saving into /tmp/mnt/test.gz with kate, with the setup described in
https://phabricator.kde.org/D14890

Diff Detail

Repository
R243 KArchive
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 1968
Build 1986: arc lint + arc unit
dfaure created this revision.Aug 17 2018, 11:06 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptAug 17 2018, 11:06 PM
Restricted Application edited subscribers, added: kde-frameworks-devel; removed: Frameworks. · View Herald Transcript
dfaure requested review of this revision.Aug 17 2018, 11:06 PM
cullmann accepted this revision.Aug 18 2018, 5:38 AM

Propagating the error is good in any case.
Will later adapt my patch to use it, like you proposed.
Still, my crash does happen independent of this I assume.

This revision is now accepted and ready to land.Aug 18 2018, 5:38 AM

Hmm, actually, that has other issues.
You can't check errorString().isEmpty() for checking if an error is there.
I just commited my other patch with the addition of that code (and was to dumb to run make test)

e.g. even after constructing a QFile, you already have:

const KCompressionDevice::CompressionType type = KFilterDev::compressionTypeForMimeType(m_mimeTypeForFilterDev);
 QScopedPointer<QIODevice> saveFile((type == KCompressionDevice::None) ? static_cast<QIODevice*>(new QFile(filename)) : static_cast<QIODevice*>(new KCompressionDevice(filename, type)));

qDebug() << "lalal file " << filename << "failed with error" << saveFile->errorString();

>

lalal file "/home/cullmann/kde/build/frameworks/ktexteditor/jsdklfjsdklffsf" failed with error "Unknown error"

cullmann requested changes to this revision.Aug 18 2018, 9:31 AM
This revision now requires changes to proceed.Aug 18 2018, 9:31 AM
dfaure updated this revision to Diff 39963.Aug 18 2018, 10:51 AM

Rework as discussed

Updating D14913: KCompressionDevice: propagate errors from QIODevice::close()

BUG: 397545

cullmann accepted this revision.Aug 18 2018, 10:57 AM

Looks reasonable, given we must live with the constraint of having error() atm only in QFileDevice.

This revision is now accepted and ready to land.Aug 18 2018, 10:57 AM
dfaure closed this revision.Aug 18 2018, 11:02 AM