[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-18 19:06:38
Message-ID: CAEPLNsf-UqXzhrpH=XGw7gipKCVJ1j6J6Mn+nhQTzbQbn2pMOg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Done.

https://quickgit.kde.org/?p=krita.git&a=commit&h=71c7b04ee73912dfc42892f2a48cb5d170ee1d12

2015-10-18 16:12 GMT+02:00 Boudewijn Rempt <boud@valdyas.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
> 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 <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?
>>
>>
>>
>>
> _______________________________________________
> Krita mailing list
> kimageshop@kde.org
> https://mail.kde.org/mailman/listinfo/kimageshop
>
>

[Attachment #5 (text/html)]

<div dir="ltr">Done.<br><br><a \
href="https://quickgit.kde.org/?p=krita.git&amp;a=commit&amp;h=71c7b04ee73912dfc42892f \
2a48cb5d170ee1d12">https://quickgit.kde.org/?p=krita.git&amp;a=commit&amp;h=71c7b04ee73912dfc42892f2a48cb5d170ee1d12</a><br><div><div \
class="gmail_extra"><br><div class="gmail_quote">2015-10-18 16:12 GMT+02:00 Boudewijn \
Rempt <span dir="ltr">&lt;<a href="mailto:boud@valdyas.org" \
target="_blank">boud@valdyas.org</a>&gt;</span>:<br><blockquote class="gmail_quote" \
style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">Hi Juan,<br> <br>
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.<span class=""><font color="#888888"><br> <br>
Boudewijn<br>
<br>
-- <br>
Boudewijn Rempt | <a href="http://www.krita.org" rel="noreferrer" \
target="_blank">http://www.krita.org</a>, <a href="http://www.valdyas.org" \
rel="noreferrer" target="_blank">http://www.valdyas.org</a></font></span><div \
class=""><div class="h5"><br> <br>
On Sat, 17 Oct 2015, Juan Palacios wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"> Another solution is to not close the device \
inside the close method of KArchive (when the device is not owned).<br> <br>
       if (d-&gt;dev &amp;&amp; d-&gt;dev != d-&gt;saveFile) {<br>
               d-&gt;dev-&gt;close();<br>
       }<br>
<br>
should be:<br>
<br>
       if (d-&gt;deviceOwned &amp;&amp; d-&gt;dev &amp;&amp; d-&gt;dev != \
d-&gt;saveFile) {<br>  d-&gt;dev-&gt;close();<br>
       }<br>
<br>
Keep in mind that i dodn&#39;t test this approach and i don&#39;t know if this is \
correct nor the implications that this change could have to other applications.<br> \
<br> More ideas?<br>
<br>
2015-10-17 19:18 GMT+02:00 Juan Palacios &lt;<a href="mailto:jpalaciosdev@gmail.com" \
                target="_blank">jpalaciosdev@gmail.com</a>&gt;:<br>
         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<br>  terminal. (This \
bug report seems to be related with this issue: <a \
href="https://bugs.kde.org/show_bug.cgi?id=352891" rel="noreferrer" \
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<br>
         state of the device (closes it on his destructor). \
QImageIOPlugin::capabilities documentation specifies that the device state should not \
be<br>  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 \
&amp;format) const<br> <br>
                ...<br>
<br>
                const QIODevice::OpenMode mode = device-&gt;openMode();<br>
<br>
                Capabilities cap;<br>
                if (device-&gt;isReadable() &amp;&amp; OraHandler::canRead(device)) \
{<br>  cap |= CanRead;<br>
                }<br>
<br>
                if (!device-&gt;isOpen())<br>
                        device-&gt;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<br>  in use \
device-&gt;peek method and extract the first 57 or 54 bytes (kra or ora), to obtain \
the &quot;application/x-krita&quot; and &quot;image/openraster&quot;<br>  \
directly.<br> <br>
         Example:<br>
         bool OraHandler::canRead(QIODevice *device)<br>
         {<br>
                if (!device) {<br>
                        qWarning(&quot;KraHandler::canRead() called with no \
device&quot;);<br>  return false;<br>
                }<br>
<br>
                char buff[54];<br>
                if (device-&gt;peek(buff, sizeof(buff)) == sizeof(buff))<br>
                        return qstrcmp(buff + 0x26, &quot;image/openraster&quot;) == \
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>
<br>
<br>
<br>
</blockquote>
</div></div><br>_______________________________________________<br>
Krita mailing list<br>
<a href="mailto:kimageshop@kde.org">kimageshop@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/kimageshop" rel="noreferrer" \
target="_blank">https://mail.kde.org/mailman/listinfo/kimageshop</a><br> \
<br></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