Comment 1 for bug 1467740

Revision history for this message
James Henstridge (jamesh) wrote :

I think this is actually on the Unity8 side rather than unity-scopes-shell.

The result cards are generated by CardCreator.js, which uses a CroppedImageMinimumSourceSize component to display the result art:

http://bazaar.launchpad.net/~unity-team/unity8/trunk/view/head:/plugins/Dash/CardCreator.js#L101

This component is implemented in QML but delegates finding the size of the image to the C++ component CroppedImageSizer

http://bazaar.launchpad.net/~unity-team/unity8/trunk/view/head:/plugins/Dash/CroppedImageMinimumSourceSize.qml

That class uses QNetworkAccessManager to try and get the file contents and uses a helper class to manage the response:

http://bazaar.launchpad.net/~unity-team/unity8/trunk/view/head:/plugins/Dash/croppedimagesizer.cpp#L102

That helper tries to read the returned data via QImageReader and passes the image size back to CroppedImageSizer:

http://bazaar.launchpad.net/~unity-team/unity8/trunk/view/head:/plugins/Dash/croppedimagesizerasyncworker.cpp#L58

If the worker provides a non-empty size, CroppedImageSizer then uses that size information to pick a sourceSize value that will result in the image being loaded at the correct size so it only has to be cropped in at most one dimension to fit. If an empty (or invalid) size is provided, it sets sourceSize to (0, 0):

http://bazaar.launchpad.net/~unity-team/unity8/trunk/view/head:/plugins/Dash/croppedimagesizer.cpp#L118

This causes a problem for the thumbnailer because QNetworkAccessManager has no idea how to deal with image:// URIs, so we get an invalid QSize from the worker and use a sourceSize of (0, 0). Perhaps it should just use the requested dimensions in this case instead. It doesn't look like there is a way to handle this crop mode properly with QQuickImageProvider.