Missing icons on all kde apps

Juan Palacios jpalaciosdev at gmail.com
Sat Oct 17 17:18:06 UTC 2015


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kimageshop/attachments/20151017/2023004c/attachment.html>


More information about the kimageshop mailing list