[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-kimageshop
Subject: Re: Missing icons on all kde apps
From: Juan Palacios <jpalaciosdev () gmail ! com>
Date: 2015-10-17 18:32:58
Message-ID: CAEPLNseL52UCvEjn93o1TUVLPzXTD5nWeA_aHFW=Nq3vZotUUw () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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 <jpalaciosdev@gmail.com>:
> 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?
>
[Attachment #5 (text/html)]
<div dir="ltr">Another solution is to not close the device inside the close method of \
KArchive (when the device is not owned).<br><br> if (d->dev && \
d->dev != d->saveFile) {<br> d->dev->close();<br> \
}<br><br>should be:<br><br> if (d->deviceOwned && d->dev \
&& d->dev != d->saveFile) {<br> \
d->dev->close();<br> }<br><br>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.<br><br>More ideas?<br><div><div \
class="gmail_extra"><br><div class="gmail_quote">2015-10-17 19:18 GMT+02:00 Juan \
Palacios <span dir="ltr"><<a href="mailto:jpalaciosdev@gmail.com" \
target="_blank">jpalaciosdev@gmail.com</a>></span>:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div dir="ltr">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: <a href="https://bugs.kde.org/show_bug.cgi?id=352891" \
target="_blank">https://bugs.kde.org/show_bug.cgi?id=352891</a>)<br><br>I found that \
this bug is caused by the QImageIOPlugin to support kra and ora formats (located on \
inst/lib64/plugins/).<br><br>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.<br><br>There are \
two ways to solve this problem:<br>The first one reopens the device at the end of \
capabilities method, but this can change the device state (read/write positions \
...).<br><br>Example for OraPlugin::capabilities(QIODevice *device, const QByteArray \
&format) const<br><br> ...<br><br> const QIODevice::OpenMode mode = \
device->openMode();<br><br> Capabilities cap;<br> if \
(device->isReadable() && OraHandler::canRead(device)) {<br> \
cap |= CanRead;<br> }<br><br> if (!device->isOpen())<br> \
device->open(mode);<br><br> ...<br><br><br>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.<br><br>Example:<br>bool \
OraHandler::canRead(QIODevice *device)<br>{<br> if (!device) {<br> \
qWarning("KraHandler::canRead() called with no device");<br> \
return false;<br> }<br><br> char buff[54];<br> if \
(device->peek(buff, sizeof(buff)) == sizeof(buff))<br> return \
qstrcmp(buff + 0x26, "image/openraster") == 0;<br><br> return \
false;<br>}<br><br><br>I already tested both fixes and seems to solve the \
problem.<br>Thoughts on this?<br></div> </blockquote></div><br></div></div></div>
[Attachment #6 (text/plain)]
_______________________________________________
Krita mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic