D19696: Add blender thumbnailer

Stefan BrĂ¼ns noreply at phabricator.kde.org
Tue Mar 12 16:12:06 GMT 2019


bruns requested changes to this revision.
bruns added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> blendercreator.cpp:57
> +    QPointer<KCompressionDevice> gzFile;
> +    if(file.peek(2).startsWith("\x1F\x8B")) { // gzip magic (each gzip member starts with ID1(0x1f) and ID2(0x8b))
> +        file.close();

I think this is already done by the calling code - the thumbnailer gets only called when the mimetype matches.

> blendercreator.cpp:62
> +            blendStream.setDevice(gzFile);
> +        }
> +    }

`} else {` ...?

> blendercreator.cpp:73
> +
> +    // Example header: "BLENDER-257"
> +

This is missing the 'v' / 'V'

> blendercreator.cpp:98
> +    }
> +    const qint32 REND = isLittleEndian ? 1145980242 /*python int.from_bytes(b'REND', byteorder='little')*/ : 1380273732;
> +    const qint32 TEST = isLittleEndian ? 1414743380 : 1413829460;

When you write these as hex, it becomes more obvious one is "REND" while the other is "DNER". Although ...

> blendercreator.cpp:101
> +    const bool is64Bit = head[7] == '-';
> +    const int fileBlockHeadSize = is64Bit ? 24 : 20; // sum(1 through 6)
> +    const int remainingHeader = fileBlockHeadSize - 8; // sum(3 through 5)

Does this mean 'size of header fields 1 to 5'?

> blendercreator.cpp:105
> +    while (true) {
> +        blendStream >>  code >> length;
> +        if (code == REND) {

... you can use `readRawData(data, 4)` here and just compare with 'REND'.

Or even always read the whole header, saving you the `skipRawData(remainingHeader)`, and gets rid of `remainingHeader`.

Actually, using `operator>>` on raw data, i.e. anything not written using QDataStream is dangerous. There is **no** guarantee an int is serialized as just 4 bytes.

REPOSITORY
  R320 KIO Extras

REVISION DETAIL
  https://phabricator.kde.org/D19696

To: chinmoyr, #frameworks, bruns
Cc: bruns, ngraham, broulik, ltoscano, kde-frameworks-devel, kfm-devel, alexde, feverfew, michaelh, spoorun, navarromorales, firef, andrebarros, emmanuelp, mikesomov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20190312/d8fa5038/attachment.htm>


More information about the kfm-devel mailing list