--===============5270476312959019342== Content-Type: multipart/alternative; boundary=001a1147e30277c375052265ba7a --001a1147e30277c375052265ba7a Content-Type: text/plain; charset=UTF-8 Done. https://quickgit.kde.org/?p=krita.git&a=commit&h=71c7b04ee73912dfc42892f2a48cb5d170ee1d12 2015-10-18 16:12 GMT+02:00 Boudewijn Rempt : > Hi Juan, > > That really is awesome detective work. I think the best option would be to > both have the peek() inside the kra/ora code and discuss whether changing > karchive makes sense on frameworks-devel. > > Boudewijn > > -- > Boudewijn Rempt | http://www.krita.org, http://www.valdyas.org > > > On Sat, 17 Oct 2015, Juan Palacios wrote: > > Another solution is to not close the device inside the close method of >> KArchive (when the device is not owned). >> >> if (d->dev && d->dev != d->saveFile) { >> d->dev->close(); >> } >> >> should be: >> >> if (d->deviceOwned && d->dev && d->dev != d->saveFile) { >> d->dev->close(); >> } >> >> Keep in mind that i dodn't test this approach and i don't know if this is >> correct nor the implications that this change could have to other >> applications. >> >> More ideas? >> >> 2015-10-17 19:18 GMT+02:00 Juan Palacios : >> I have been having some problems with missing icons on all kde apps >> and the message QIODevice::seek (QBuffer): The device is not open on the >> terminal. (This bug report seems to be related with this issue: >> https://bugs.kde.org/show_bug.cgi?id=352891) >> >> I found that this bug is caused by the QImageIOPlugin to support >> kra and ora formats (located on inst/lib64/plugins/). >> >> KZip is used to read the contents of the file through the device on >> canRead(QIODevice *device) method. The problem is that KZip changes the >> state of the device (closes it on his destructor). >> QImageIOPlugin::capabilities documentation specifies that the device state >> should not be >> changed. >> >> There are two ways to solve this problem: >> The first one reopens the device at the end of capabilities method, >> but this can change the device state (read/write positions ...). >> >> Example for OraPlugin::capabilities(QIODevice *device, const >> QByteArray &format) const >> >> ... >> >> const QIODevice::OpenMode mode = device->openMode(); >> >> Capabilities cap; >> if (device->isReadable() && OraHandler::canRead(device)) { >> cap |= CanRead; >> } >> >> if (!device->isOpen()) >> device->open(mode); >> >> ... >> >> >> The other one is prone to future breaks if the kra or ora internals >> are changed in some way, but it will not change the device state. Consists >> in use device->peek method and extract the first 57 or 54 bytes >> (kra or ora), to obtain the "application/x-krita" and "image/openraster" >> directly. >> >> Example: >> bool OraHandler::canRead(QIODevice *device) >> { >> if (!device) { >> qWarning("KraHandler::canRead() called with no device"); >> return false; >> } >> >> char buff[54]; >> if (device->peek(buff, sizeof(buff)) == sizeof(buff)) >> return qstrcmp(buff + 0x26, "image/openraster") == 0; >> >> return false; >> } >> >> >> I already tested both fixes and seems to solve the problem. >> Thoughts on this? >> >> >> >> > _______________________________________________ > Krita mailing list > kimageshop@kde.org > https://mail.kde.org/mailman/listinfo/kimageshop > > --001a1147e30277c375052265ba7a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Done.

http= s://quickgit.kde.org/?p=3Dkrita.git&a=3Dcommit&h=3D71c7b04ee73912df= c42892f2a48cb5d170ee1d12

2015-10-18 16:12 GMT+02:00 Boudewijn Rempt <boud@valdya= s.org>:
= Hi Juan,

That really is awesome detective work. I think the best option would be to = both have the peek() inside the kra/ora code and discuss whether changing k= archive makes sense on frameworks-devel.

Boudewijn

--
Boudewijn Rempt | http://www.krita.org, http://www.valdyas.org


On Sat, 17 Oct 2015, Juan Palacios wrote:

Another solution is to not close the device inside the close method of KArc= hive (when the device is not owned).

=C2=A0=C2=A0=C2=A0 if (d->dev && d->dev !=3D d->saveFile) = {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 d->dev->close();
=C2=A0=C2=A0=C2=A0 }

should be:

=C2=A0=C2=A0=C2=A0 if (d->deviceOwned && d->dev && d-= >dev !=3D d->saveFile) {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 d->dev->close();
=C2=A0=C2=A0=C2=A0 }

Keep in mind that i dodn't test this approach and i don't know if t= his is correct nor the implications that this change could have to other ap= plications.

More ideas?

2015-10-17 19:18 GMT+02:00 Juan Palacios <jpalaciosdev@gmail.com>:
=C2=A0 =C2=A0 =C2=A0 I have been having some problems with missing icons on= all kde apps and the message QIODevice::seek (QBuffer): The device is not = open on the
=C2=A0 =C2=A0 =C2=A0 terminal. (This bug report seems to be related with th= is issue: https://bugs.kde.org/show_bug.cgi?id=3D352891= )

=C2=A0 =C2=A0 =C2=A0 I found that this bug is caused by the QImageIOPlugin = to support kra and ora formats (located on inst/lib64/plugins/).

=C2=A0 =C2=A0 =C2=A0 KZip is used to read the contents of the file through = the device on canRead(QIODevice *device) method. The problem is that KZip c= hanges the
=C2=A0 =C2=A0 =C2=A0 state of the device (closes it on his destructor). QIm= ageIOPlugin::capabilities documentation specifies that the device state sho= uld not be
=C2=A0 =C2=A0 =C2=A0 changed.

=C2=A0 =C2=A0 =C2=A0 There are two ways to solve this problem:
=C2=A0 =C2=A0 =C2=A0 The first one reopens the device at the end of capabil= ities method, but this can change the device state (read/write positions ..= .).

=C2=A0 =C2=A0 =C2=A0 Example for OraPlugin::capabilities(QIODevice *device,= const QByteArray &format) const

=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 ...

=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 const QIODevice::OpenMode mode =3D = device->openMode();

=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 Capabilities cap;
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 if (device->isReadable() &&a= mp; OraHandler::canRead(device)) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cap |=3D Ca= nRead;
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 }

=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 if (!device->isOpen())
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 device->= open(mode);

=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 ...


=C2=A0 =C2=A0 =C2=A0 The other one is prone to future breaks if the kra or = ora internals are changed in some way, but it will not change the device st= ate. Consists
=C2=A0 =C2=A0 =C2=A0 in use device->peek method and extract the first 57= or 54 bytes (kra or ora), to obtain the "application/x-krita" an= d "image/openraster"
=C2=A0 =C2=A0 =C2=A0 directly.

=C2=A0 =C2=A0 =C2=A0 Example:
=C2=A0 =C2=A0 =C2=A0 bool OraHandler::canRead(QIODevice *device)
=C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 if (!device) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qWarning(&q= uot;KraHandler::canRead() called with no device");
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return fals= e;
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 }

=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 char buff[54];
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 if (device->peek(buff, sizeof(bu= ff)) =3D=3D sizeof(buff))
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return qstr= cmp(buff + 0x26, "image/openraster") =3D=3D 0;

=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 return false;
=C2=A0 =C2=A0 =C2=A0 }


=C2=A0 =C2=A0 =C2=A0 I already tested both fixes and seems to solve the pro= blem.
=C2=A0 =C2=A0 =C2=A0 Thoughts on this?




_______________________________________________
Krita mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop=


--001a1147e30277c375052265ba7a-- --===============5270476312959019342== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KS3JpdGEgbWFp bGluZyBsaXN0CmtpbWFnZXNob3BAa2RlLm9yZwpodHRwczovL21haWwua2RlLm9yZy9tYWlsbWFu L2xpc3RpbmZvL2tpbWFnZXNob3AK --===============5270476312959019342==--