Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-19504

qml docs wrongly mention QPixmapCache as a caching system used for "any image loaded by QML"

    XMLWordPrintable

Details

    • 7602be09663d37f01cfd640a7f1be959ce4317b7

    Description

      Docs of QDeclarativeEngine say:

      Note that images loaded from a QDeclarativeImageProvider are cached by QPixmapCache, similar to any image loaded by QML.

      Now, it seems that this piece of docs comes from the initial commit b77e592cf9709c31f61c3e1d229b2a6c446ab8bc (b77e592c). Back then indeed this was true. qt/src/declarative/util/qmlpixmapcache.cpp contained e.g. the following piece of code:

      bool QmlPixmapReply::event(QEvent *event)
      ...
                  QPixmapCache::insert(strKey, d->pixmap); // note: may fail (returns false)
      

      Thus back then qmlpixmapcache.cpp indeed used QPixmapCache in the background. But since then the code has changed: if I understand correctly, the way it works now is:

      • QDeclarativeImagePrivate has "QDeclarativePixmap * pix" member
      • setting Image { source : "http://www.google.nl/intl/en_com/images/srpr/logo1w.png" }

        sets the source of pix to provided url

      • QDeclarativePixmap has its own cache QDeclarativePixmapStore, which seems completely independent of QPixmapCache.
        See the following two lines in current qdeclarativepixmapcache.cpp:
        Q_GLOBAL_STATIC(QDeclarativePixmapStore, pixmapStore);
        
        void QDeclarativePixmapData::addToCache()
        ...
        	pixmapStore()->m_cache.insert(key, this);
        

      It is really misleading. We have in our project several large pictures used as qml Image source and they seemed not to be cached even if we increased cache limit of QPixmapCache - well, no wonder, considering that qml seems not to be using QPixmapCache at all (and uses QDeclarativePixmapStore instead, with an independent cache limit, very small in the case of QWS)!

      But please, check this with qml guys, I might be wrong! (Side remark: it seems that QPixmapCache is in fact used in qml but only for frames of rounded rectangles and for border images; both seem independent of the story above which is about general caching of sources of qml Image).

      Anyway, I attach a patch which changes the above text to:

      Note that images loaded from a QDeclarativeImageProvider are cached in an internal qml cache, similar to any image loaded by QML.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              bealam Bea Lam (closed Nokia identity) (Inactive)
              wiecko Marek Wieckowski
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes