karchive and QSaveFile (fwd)
Boudewijn Rempt
boud at valdyas.org
Wed Mar 29 12:40:10 UTC 2017
Hi,
I'm trying to make Krita use QSaveFile instead of the home-grown
mess of temporary files that get copied over the original file
after saving succeeded. The problem is that Krita, like Calligra,
uses KArchive. And KArchive, even when a KZip is created with
an existing QIODevice, decides on its own to call close(), which
is not allowed with QSaveFile.
I've tried to set KZip's io device to 0 just before closing the
kzip, but that means the zip file doesn't get written correctly.
I've got a hack around that... I've made a tiny subclass of KZip:
class SaveZip : public KZip {
public:
SaveZip(const QString &filename) : KZip(filename) {}
SaveZip(QIODevice *dev) : KZip(dev) {}
virtual ~SaveZip() {}
void resetDevice() {
closeArchive();
setDevice(0);
}
};
And call resetDevice before deleting or closing the kzip instance
in KoStore.
But that's a hack, and I'm now wondering whether to hack QSaveFile's
close() to just not abort, or add inherits("QSaveFile") checks all
over KArchive -- or whether there's a third, better option that I've
missed...
--
Boudewijn Rempt | http://www.krita.org, http://www.valdyas.org
More information about the Kde-frameworks-devel
mailing list