Details
-
Task
-
Resolution: Unresolved
-
P2: Important
-
None
Description
Currently image providers are registered on a per engine basis, something we'd like to avoid in the future if at all possible.
The one reason to have a non-optional plugin with an initializeEngine() method is to add an image provider that lives in the plugin to the engine. We want to get rid of non-optional plugins. All plugins without image providers in Qt that I have seen can be made optional.
Some observations:
- The QML engine itself does not do anything with the image providers. It only stores them.
- The pixmap cache is the only place where image providers are actually used. The pixmap cache is a completely unprotected global static.
- The usual initializeEngine() methods in image provider-based plugins just indiscriminately add the image provider to any engine that shows up. How would they discern between engines anyway? Of course someone might have come up with a way to pass information via objectName() or similar. So, we probably need to keep this association around somewhere.
- The QML engine takes ownership of image providers by storing them in a QSharedPointer. The pointer is never shared with anything.
- We also have another global static map of pixmap readers, keyed by QQmlEngine: QQuickPixmapReader::readers.
So, how can we redesign this?
- We need the image providers to be stored somewhere else
- We need to allow an image provider to be associated with a QML engine for backwards compatibility
An obvious solution would be to add a static method to QQuickImageProvider that adds an image provider to the global pixmap cache and on access search that in addition to the engine-specific image providers. The question is then how to statically add pixmap providers to this cache on loading. We have Q_CONSTRUCTOR_FUNCTION, but that still doesn't work in various cases as linkers tend to optimize it away.
One thing we might do is add a QML_CONSTRUCTOR_FUNCTION(globalFunction) to the list of QML macros. qmltyperegistrar would just generate a call to globalFunction() into the type registration function. Then you could define a function that adds the image provider to the pixmap cache and have that executed when importing the module. We'd conveniently chain this to the static initialization problem we already have ...
Attachments
Issue Links
- depends on
-
QTBUG-108146 move remote resource loading from Qt Quick to QtCore
- Reported
- is duplicated by
-
QTBUG-94592 Reconsider image provider setup and ownership
- Reported
- is required for
-
QTBUG-82767 QML plugins are redundant
- Open
- relates to
-
QTBUG-110506 QtQuickTemplates2Plugin uses registerTypes() and unregisterTypes()
- Reported
-
QTBUG-84314 Fix QQuickPixmapCache to cache large images rendered by complex image plugins, and dispose via LRU algorithm
- Closed
-
QTBUG-81266 figure out whether QPixmapCache and QQuickPixmapCache can be unified
- Reported
-
QTBUG-77506 develop PDF rendering strategy for Qt Quick
- Closed
- mentioned in
-
Page Loading...