aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickpixmapcache.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Set explicit default security level of all files with default securityJan Arve Sæther2025-09-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The files (folders) already processed are listed in each issue in epic QTBUG-134547 These files were processed half a year ago. In order to make it clear that all of these files are already processed, mark them with an explicit default security header. For the record, this was generated with this script: find -E . -regex ".*\.(cpp|h|hpp|mm|qml|js)$" | xargs python3 ~/bin/add-cra-header.py in the folders listed in each subtask of QTBUG-134547 (add-cra-header.py only exist at my desktop, but it simply adds the default security header if it doesn't already have any existing security header) QUIP: 23 Fixes: QTBUG-134547 Pick-to: 6.10 6.9 6.8 Change-Id: Ieb8c78ea6561fdbdd27c7b13185ece853eedf80f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* QQuickPixmapReader: Trigger typeloader creation before thread startUlf Hermann2025-06-241-0/+5
| | | | | | | | | | | The type loader can be requested from different threads but should be created on the engine thread. Amends commit d2bc4a4330254c0c68a0ade51b59a71c4b67b470 Fixes: QTBUG-137848 Change-Id: I30d93e6351bd67ded94956f9832cb87157823373 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Hold QQmlTypeLoader in QV4::ExecutionEngineUlf Hermann2025-06-171-1/+1
| | | | | | | | | | | ... rather than QQmlEngine. This paves the way for having the type loader attached to ExecutionEngine rather than QQmlEngine. Also, reference the execution engine in the type loader, in turn. Task-number: QTBUG-19407 Change-Id: I04e571c5c6ac5bce5e82537cb96c6940c7186f3a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Abort QQuickPixmap::load if the QQmlEngine is nullTian Shilin2025-04-151-4/+4
| | | | | | | | | | | | | | | | | If engine is nullptr, calling QQmlEnginePrivate::get(engine) will cause the program to crash trying to access an uninitialized object. The only useful thing this function can do if the engine is null is to find and return a cached image, if any. However, in 0290e0fd5285cd48809ade02ce2e67a423ba3152 it was possible to test QQuickDragAttached without an engine; now there needs to be one associated via a QQmlContext for this test to continue to pass. Pick-to: 6.8 6.9 Change-Id: I28596c2063f0474fc97b2e9a3907f8bb38c78cb1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add 16-bit/32-bit floating point support for QSGPlainTextureKristoffer Skau2025-03-241-2/+20
| | | | | | | | | | | | | | | | Part of the HDR story is loading images that contain pixel values in bigger ranges than between 0 and 1. QQuickDefaultTextureFactory and QSGPlainTexture automatically converts QImages to RGB(A) 32-bit and textures to RGB(A/X) 8-bit, which are non-floating point based. This change adds support for the additional formats required, which are 16 and 32 bit floating point. It will fall back to 16 bit fp textures if RHI does not support fp 32, and down to the default 8 bits if fp 16 is not supported either. Task-number: QTBUG-126035 Change-Id: I6366f04af26126978e087301108af020749bae54 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Quick: #include mocsThiago Macieira2025-02-071-0/+1
| | | | | | | | | | | | I suspect this is related to why MSVC appears to require a QESDP destructor symbol, but it's idiomatic Qt, so do it independent of the ~QESDP problem. Task-number: QTBUG-133494 Task-number: QTBUG-102948 Pick-to: 6.9 Change-Id: Idedd6d2b552d44f41d48fffdc3d61968a939b530 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtQml: Move network access manager factory into type loaderUlf Hermann2025-01-081-1/+1
| | | | | | | | | | It's used from both, the type loader and the engine thread, and also from worker scripts. Add a comment to explain why it needs a separate mutex. Task-number: QTBUG-131721 Change-Id: I12ec2fe462349b3ad5f34262d3f43dfa78f0487f Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Use QPointer for QQuickPixmapData::specialDevice; abort if deletedShawn Rutledge2024-10-031-7/+22
| | | | | | | | | | | | | | | | | | | | | QQuickPdfPageImage::load() calls carrierFile() to get a QPdfFile instance, a subclass of QIODevice, and calls QQuickPixmap::loadImageFromDevice() which saves the device to QQuickPixmapData::specialDevice, then calls QQuickPixmapReader::startJob() which sends a ProcessJobs event. The worker thread handles it in QQuickPixmapReader::processJob() and calls readImage(), passing a simple QIODevice *dev. readImage() relies on that pointer being valid until the work is done. However, QQuickPdfDocument::setSource() may have called deleteLater(). We can detect it, and in that case there is no point in continuing this render job. Also, change QPdfFile's thread affinity to the renderer thread, so that deletion cannot happen until after readImage() is done and the renderer thread has returned to its event loop. Fixes: QTBUG-128875 Pick-to: 6.8 6.7 6.5 Change-Id: I1e8bf526c5596ce561d7bf4f7dea8d50f3c0eb18 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Logging: use qCDebug/Warning/Info for categorized loggingVolker Hilsheimer2024-07-171-1/+1
| | | | | | | | | | | | | When building qt with QT_NO_DEBUG/WARNING/INFO_OUTPUT set, then the qDebug/Warning/Info macros expand to `QMessageLogger::noDebug`. That helper is not defined to take a logging category or category function, so using `qDebug(lcX, ...)` breaks the build. The correct way to emit categorized logging is to use the qCDebug/Warning/Info macros. Task-number: QTBUG-125589 Pick-to: 6.8 6.7 6.5 Change-Id: Ia7043403aad4e8d4c7c081598e4a556e7ef8461a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Take care of asyncResponses when qml_network is disabledFatih Uzunoglu2024-06-241-10/+9
| | | | | | | | | | In qquickpixmapcache.cpp the ifdef's need moving to support non-network async image fetching. Fixes: QTBUG-126628 Pick-to: 6.5 6.7 6.8 Change-Id: Ia8ab97684a815176cfd80ac16015403d91f84bcf Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QtQuick: Straighten out some logging categoriesUlf Hermann2024-06-191-3/+1
| | | | | | | | | | | | Either make them static or declare them in a header. We want them to be static wherever possible, in order to reduce the number of visible symbols. If they can't be static, however, they should at least be declared in only one place. Task-number: QTBUG-67692 Change-Id: I485bb7e4379e86f72619f848399ad58c76586851 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickText: consider DPR when drawing scalable inline imagesVladimir Belyavsky2024-05-071-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | Take into account the device pixel ratio when drawing scalable inline images (such as SVG, SVGZ, PDF) in QML Text. Thus we can improve the image rendering quality, especially for cases when the image size is set explicitly. Consider the following case: Text { text: '<img src="foo.svg" width="16" height="16"/>' } In case the device pixel ratio is e.g. 1.5, we loaded the SVG file into 16x16 QImage and after that we upscaled it as a raster to 24x24 with quality loss. Now we consider DPR when loading the image. Note: this change improves only rendering for scalable images and do not provide the support for "@2x" raster resources. But this can be done in future changes. Fixes: QTBUG-113040 Pick-to: 6.7 Change-Id: I8baada728e9acec5528553d0616ac37994ab80b6 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Get rid of QQuickTextDocumentWithImageResourcesShawn Rutledge2023-12-041-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Users want to be able to provide their own QTextDocument instances to TextEdit; but we had been creating a subclass called QQuickTextDocumentWithImageResources, which was an obstacle for that. QTextDocumentPrivate has two QMaps to hold resources, but QQuickTextDocumentWithImageResources existed for the purpose of caching remote resources, which only QQuickPixmap knows how to fetch. (This design was apparently invented as a workaround to the lack of virtual-filesystem functionality in Qt Core. If QtCore already knew how to fetch web resources from URLs in the background, QTextDocument could use it to do its own fetching of remote resources.) What we want instead of subclassing QTextDocument is to keep doing the fetching in Qt Quick (because there's no other choice for now), but get the images into the same QTextDocumentPrivate::cachedResources map where local-file resources are cached. As it turns out, since qtbase ac300a166f801a6f6c0b15278e6893720a5726f8 QTextDocument::loadResource() can use QMetaMethod::invoke() to call a method with the signature QVariant loadResource(int,QUrl) if such a method is found in QTD's parent object; so since QQuickTextEdit creates its own document by default, and is the document's parent, we can keep remote resource fetching functionality working by 1) providing the QQuickTextEdit::loadResource() method to be invoked, and 2) moving the document to the QML thread so that it can be invoked directly. (QMetaMethod::invoke() doesn't work across a queued connection, because we need to return a value: the QVariant.) QTD will already cache the images as soon as the call to loadResource() returns a valid QVariant. We ask for the QQuickPixmap not to be cached by passing an empty QQuickPixmap::Option enum to its ctor, which gets passed through to the load() function. When we consider fetching resources from a web server, it's unfortunate that the signature of QTextDocument::resource() sets the expectation that resources can be loaded immediately. But as long as QQuickTextEdit::loadResource() is waiting for fetching to be done, it keeps returning a default-constructed QVariant, which won't be cached; and it will be called again later, repeatedly, until it eventually succeeds. To ensure that it is called again when fetching is done, we call QTextDocument::resource() again, to provoke it to call our QQuickTextEdit::loadResource() one last time. If the returned image wasn't cached before, it will be after that. Then it's ok to delete the QQuickPixmap, and invalidate the TextEdit so that layout will be updated to include the image, now that we have it. But most of the time it's relatively boring: QTextDocument knows how to load local files on its own, and caches them. So we no longer need QQuickTextDocumentWithImageResources. But we still needed to replace QTextImageHandler with a custom implementation, as explained in bab2eaf3da299c471dd898c89cf356984b077412: we need QQuickPixmap for its QML-specific URL resolution relative to the Text item's context. And it turns out that in case the document contains only a missing image, the minimum size is 16x16 pixels, to reserve space to display a "broken image" icon as browsers sometimes do... we have never actually done that in Qt Quick AFAICT, but autotests have been enforcing the 16x16 minimum size all along. This is done in QQuickTextImageHandler::intrinsicSize() now. The same approach is taken with Text (when textFormat is RichText or MarkdownText. In case of StyledText, there is no QTextDocument instance, and resource loading is taken care of entirely within QQuickText.) For the autotests, friendly use of QQuickPixmapCache::m_cache requires QT_BEGIN_NAMESPACE. Task-number: QTBUG-35688 Change-Id: I8ad8142b3b3790254dd56d6cfe5209d641465f08 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove QQuickPixmap argument from QQuickPixmapData ctorsShawn Rutledge2023-09-101-22/+18
| | | | | | | | | | | | | | | | We don't use it anymore. QQuickPixmapData is the PIMPL behind QQuickPixmap, and e.g. QObjectPrivate has a Q pointer, so to follow the pattern, QQuickPixmapData should too. But QQuickPixmapData is reference-counted and can act as the private data for multiple QQuickPixmap instances, in case the same image is shown multiple places in a UI. Since it lives independently, and we never needed the QIntrusiveList of Q-pointers for anything more than leak prevention, there's no need to pass it to the ctor either. Change-Id: I096b0b7cf0c19821b95e30dc99d07665b82a811e Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Remove QQuickPixmapData::declarativePixmapsShawn Rutledge2023-09-101-19/+4
| | | | | | | | | | | | | | | | | | On one hand, most private classes have q-pointers; but - this list wasn't used for anything more than leak prevention (since b99c9490c398fb4d285d5f28edd553445b76d79f) - QQuickPixmapData is a bit more independent than a QObjectPrivate: it has its own reference counting, and one instance can be the PIMPL behind multiple QQuickPixmap instances - we have other mechanisms for leak prevention now (release() in various scenarios, prevUnreferenced/nextUnreferenced, purging QQuickPixmapStore::m_cache at shutdown), so this looks redundant - the longer-term owner of the QQuickPixmapData instances is QQuickPixmapStore::m_cache - QIntrusiveList is confusing and unusual Change-Id: I1f427addb1f1a05b1efe156c9e9a102dcbb730b5 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Test QQuickPixmap::loadImageFromDevice()Shawn Rutledge2023-09-091-9/+30
| | | | | | | | | | | | | | SlowProvider is slow like QPdfIOHandler is; it's a QQuickImageProvider rather than a QImageIOHandler for ease of testing, and we invoke it via a QQuickImage subclass that calls QQuickPixmap::loadImageFromDevice(), like QQuickPdfPageImage does. Also get the old dataLeak() test running, as a drive-by. It still isn't useful in CI though, because it has no built-in way of detecting leaks. Task-number: QTBUG-114953 Change-Id: I9e2950fbaf4ea69969b3bd10a0d8e624f0e4e8c1 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Export QQuickPixmapKey and (renamed) QQuickPixmapCache for autotestsShawn Rutledge2023-09-011-75/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | We need to be able to do a leak check in tst_qquickpixmapcache. So we also need to use the singleton pattern rather than Q_GLOBAL_STATIC. Since it gets more exposed this way, make the badly-encapsulated parts of API available only to friends. It's always been bothersome that various other places in the code are including qquickpixmapcache_p.h to get QQuickPixmap, and qquickpixmapcache_p.h also does not include any class called QQuickPixmapCache as you'd expect; while arguably, QQuickPixmapStore is the cache. Often in comments I've needed to refer to "the code in qquickpixmapcache.cpp" because it's a very private, inbred family of related classes that don't match the header name. So now we split the headers: qquickpixmapcache_p.h is for the cache, which is now called QQuickPixmapCache; and qquickpixmap_p.h is the header most often needed in other places. Most classes in qquickpixmap_p.h are exported, but QQuickPixmapCache itself is not (except for autotests). It cannot be defined in the header that gets included in Particles for example: then it wouldn't link, because the implementation is not (and shouldn't be) exported, and that's not what Particles needs anyway. Task-number: QTBUG-81266 Task-number: QTBUG-114953 Change-Id: Ifd7f253b8bbaa130eb52d5546f342754f99f47bb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix memory leak in qquickpixmapcacheShawn Rutledge2023-08-311-12/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QtPdf depends on QQuickPixmap::loadImageFromDevice() to pass a QPdfFile (which carries a pointer to the QPdfDocument) down into QPdfIOHandler so that it can avoid needing to reopen the document. But the introduction of loadImageFromDevice(), and then using the pixmap cache so intensively to store a lot of rendered PDF pages, revealed a drastic memory leak: many QQuickPixmapData instances remained in QQuickPixmapStore::m_cache long after their refCounts became 0. Quick scrolling through a PdfMultiPageView (especially if the zoom level is also being changed dynamically) can easily generate a lot of page-rendering jobs, some of which get cancelled early because the view has moved on to other pages and/or zoom levels. Here are several related fixes: - QQuickPixmapReader::getImage() creates a "job" represented by the QQuickPixmapReply that is returned, but now we start the job in a separate method, to ensure that QQuickPixmap::loadImageFromDevice() succeeds in connecting the QQuickPixmapReply::destroyed() signal before the job completes and deletes itself. - Use a QMutex to prevent QQuickPixmapStore::m_cache reentrancy: Rarely, a crash was possible when QQuickPixmapStore's QHash m_cache was modified between QHash::find() and dereferencing the iterator it returns, e.g. in QQuickPixmap::loadImageFromDevice(). - QQuickPixmapData::release() is needed in a few more places. - QQuickPixmapReply::finished isn't emitted if the job is cancelled, so the lambda that called oldD->release() wasn't called, and that was the remaining leak. We tried connecting QObject::destroyed() earlier, but it was causing a crash because the mutex to protect m_cache from simultaneous modification and QHash::find() was not in place. Now it seems ok. - Show "Number of leaked pixmaps: 0" in the qt.scenegraph.leaks logging category to make verification less ambiguous. Pick-to: 6.2 6.5 6.6 Task-number: QTBUG-114953 Change-Id: I11518ccf28ee5a5055ae745a5921837d2f3151b6 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Disable copy of classes in qquickpixmapcache; QQuickPixmapKey -> structShawn Rutledge2023-08-301-2/+10
| | | | | | | Verify that the known memory leak is not a result of bad copying. Change-Id: Ie1c3146981e4a33a66624ad7dcb41d46b933431b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Avoid unsigned->signed refCount conversion underflowShawn Rutledge2023-08-291-1/+1
| | | | | | | | | | | refCount is uint; there's no reason to convert it to int, even though it's normally small enough to fit. Avoid warnings both now and in the future by using auto. Pick-to: 6.5 6.6 Task-number: QTBUG-114953 Change-Id: I93fd50b78bcf371f9ba56c6626334b435bac0e7d Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Remove QML_LEAK_CHECKShawn Rutledge2023-08-211-2/+4
| | | | | | | | | | | Using an env var to enable specific debug output has been obsolete ever since we added categorized logging. [ChangeLog][QtQuick][SceneGraph] The environment variable QML_LEAK_CHECK is replaced by the logging category qt.scenegraph.leaks. Change-Id: I33b6f100df99eb558e2715d39d833e813ecde20d Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Add categorized logging and internal doc to QQuickPixmapCacheShawn Rutledge2023-07-271-4/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm perpetually confused by this code and need docs for the next time I try to read it. The implementation detail that QQuickPixmapData::prevUnreferenced and nextUnreferenced are used to form a linked list of unreferenced pixmaps is from 09f07b98dfdaec2e48749768b967a48e588d3f7f (Qt 4.7). The doc comment for QQuickPixmap is derived from that commit message. The allegation in that commit message that "QPixmapCache ... can stop expiring items in some conditions" may have been fixed in qtbase 7ab0bed3a56d46c386e65abc381264c57137cb43 (QTBUG-21359) although I'm not sure if it's the same bug to which he was referring. The bogus comment by cache_limit was also not helping: this is not the same as the limit in QPixmapCache, neither numerically nor in meaning. It was added in 4e9301e3d53febcf6b0dfe108c4189c2982952ff but qtbase 1582407fc782c0befd0760633324dd5c206524a1 removed the different value for embedded platforms. b99c9490c398fb4d285d5f28edd553445b76d79f added QIntrusiveList declarativePixmaps which is yet another kind of linked list, only to prevent a memory leak at destruction (QTBUG-22742). Pick-to: 6.6 Task-number: QTBUG-84314 Change-Id: I60ad33f8748527e91399a844547f7b7be2c931fb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Normalize signal/slot signaturesMarc Mutz2023-07-121-1/+1
| | | | | | | | | | | | | | This is the result of running util/normalize on the code base. The following manual edits were needed: - skipped the hits in IS_SIGNAL_CONNECTED, which is using function pointers under the hood - restored the space before * in Q_SIGNAL void foo(QType *arg) Pick-to: 6.6 Change-Id: I299b3747c1aa2f6b3bc5ae1794edeb6fadfd75c6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQuickPixmap: get rid of manual processing of HTTP redirectsVladimir Belyavsky2023-07-041-25/+1
| | | | | | | | | | Since d12afeff4097dd78f1311511e0c8f74e1a810d47 (Qt 6.0) QNAM has started internal processing of HTTP redirects by default. So it seems we can simply get rid of manual processing of HTTP redirects on Qt Quick level. Moreover it looks like we never even reached this code since Qt 6.0. Change-Id: I07347d3a4fb13598a8dda69085e5db9a6eaeaf85 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Introduce a new feature: quick-pixmap-cache-threaded-downloadMikolaj Boc2023-03-201-24/+47
| | | | | | | | | | | | | | | | The new feature replaces USE_THREADED_DOWNLOAD in qquickpixmapcache. Some code has been removed when it is not used: - eventLoopQuitHack - not needed as event loop is not used with the feature off - mutex - thread synchronization measures are not needed if threads are not used Also, perform last job housekeeping in ~QQuickPixmapCache sync with threaded downloads disabled. Change-Id: Ic67385c94bbe403ed0544e78f30e7c237b4f4a95 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Make thread affinity apparent in QQuickPixmapCacheMikolaj Boc2023-03-171-49/+114
| | | | | | | | | | | | | | | Introducing a new name for the former QQuickPixmapReaderThreadObject: ReaderThreadExecutionEnforcer, which describes its (sole) purpose, as opposed to the former. Added a thread affinity marker to check threading assumptions in QQuickPixmapReaderThreadObject. Also made an alias for the event ReaderThreadExecutionEnforcer sends to trigger processJobs on the original reader on its thread. Change-Id: I022374775eaa417f8568a7297b44b028db7ff0ee Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Rename cancelled -> cancelledJobs in QQuickPixmapCacheMikolaj Boc2023-03-171-16/+16
| | | | | | | | Thus improving readability, as cancelled might be confused with a cancellation flag. Change-Id: Ib7b24e58458e138ca1f653d5342e3d00f01a0f96 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add MethodIndex to meta method index statics in QQuickPixmapCacheMikolaj Boc2023-03-161-29/+36
| | | | | | | | Thus improving readability, as the fields won't be confused with actual methods. Change-Id: I7ff390fffd97042180bc6d9321fb967569e67a93 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use mutex locker in QQuickPixmapReaderMikolaj Boc2023-03-161-49/+49
| | | | | | | | Transition to the QMutexLocker for a more fail-safe and idiomatic approach to locking the mutex Change-Id: I97cfb05e8bddfd4c67b14b1db6bc457eb8e6d4c9 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickPixmapCache: own thread object if not using threaded downloadMikolaj Boc2023-03-151-21/+47
| | | | | | | | | | If threaded download is not used, we rely on async callbacks to drive the download. We can also safely own the thread object since all operations are executed on exactly one thread. Fixes: QTBUG-111892 Change-Id: I17f927f383f7a3a28d26a128b3f9e7ce1dbfe8be Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QtQuick: Fix conflicting definitions of qsg_leak_check in CMake Unity ↵Friedemann Kleint2023-02-071-5/+2
| | | | | | | | | | | (Jumbo) builds Make it a properly prefixed global variable. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Ia09072bf6603c3566484f5361b03f1d3a2164be3 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* QQuickPixmapCache: Avoid cross-thread deletion of QObjectsUlf Hermann2023-01-251-9/+40
| | | | | | | | | | | | | The threadObject is not actually owned by the the class, but rather by the thread that creates it. Make sure to delete it in the same thread. Amends b94bbd7a0b032eb6428d44bfb86feac577786a1f Pick-to: 6.5 Fixes: QTBUG-110590 Change-Id: I59d0175cf558ab3523c03a288668e1876b7329e8 Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Clean QQuickPixmapReader::processJob dead codesJiDe Zhang2022-12-051-2/+1
| | | | | Change-Id: Id0d8c6538d2648bb9fb345202486872be933e074 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Don't used threaded pixmap downloads on WASMMikolaj Boc2022-10-221-5/+12
| | | | | | | | | | | | | | WASM sockets rely on async callbacks that won't arrive when a thread is waiting on a condition in QEventDispatcherWasm::wait. The thread deadlocks, as the condition will not ever be signaled, since that relies on the async callback from emscripten_fetch being issued. Because WASM networking is non-blocking anyway, we forgo using the threaded download altogether. Change-Id: Ic75bcf7dd6272a6d3ea7b934807fcc74458b13ba Fixes: QTBUG-106159 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Use a smart pointer for threadObject in pixmap cacheMikolaj Boc2022-10-201-13/+8
| | | | | | | This enables us to forgo manual object lifetime control. Change-Id: I50894d685d98eae8b18d49c52eafa66984a8429f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-3/+3
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-6/+6
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid dangling pointers in handler for QQuickPixmapReply::finishedShawn Rutledge2022-09-111-2/+1
| | | | | | | Pick-to: 6.4 6.4.0 Fixes: QTBUG-106357 Change-Id: I78156b403618c88da26d381be7a6e777a6d22f87 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Support compressed texture files also when non-local, i.e. downloadedEirik Aavitsland2022-08-301-8/+22
| | | | | | | | | | | QQuickPixmapCache has three code paths where external data is loaded into images/textures: For local files, for local files in async mode, and for downloaded files. Handling of compressed trexture files was added to the two former, but not the latter. This commit fixes that. Fixes: QTBUG-105941 Change-Id: I6d093f9dfcd78951b81a790776509efc336e30ba Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Make synchronization chain on QQuickImageResponsePrivate::finished explicitMarc Mutz2022-06-151-0/+2
| | | | | | | | | | | Use explicit storeRelease() to match the loadAcquire() in QQuickPixmapReader and add comments linking the endpoints together. As a drive-by, make the QAtomic a bool instead of a qint32. Pick-to: 6.4 Change-Id: I8f911ad383a8095fc3e3f0cef2d663c977e87484 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Allow loading images from arbitrary QIODevice subclassesShawn Rutledge2022-02-171-29/+85
| | | | | | | | | | | | | | | | | | | For PDF we need to pass a document object into QPdfIOHandler, but QImageIOHandler only takes a QIODevice. A subclass of QFile is one way to pass that extra object along. So the plan is that a private PDF document wrapper class can inherit QFile; and there will be a subclass of QQuickImage called PdfPageImage, which will override QQuickImage::load() to construct the wrapper, which will then get sent as QIODevice* into QPdfIOHandler. It will attempt to cast that to the known private class; if it succeeds, it already will have the FPDF_Document and will therefore not need to construct one. Task-number: QTBUG-77506 Task-number: QTBUG-83988 Task-number: QTBUG-96574 Change-Id: I19c90a9f2c7060574720f831b3394de6c3714383 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Avoid acccessing global static during destructionFabian Kosmale2021-12-151-10/+15
| | | | | | | | | | | | | | | | | We cannot access the global static through its accessor function anymore while its dtor is running (due to a recent change in qtbase). However, to properly keep the removal showing in the profiler, we still want to execute removeFromCache. As we know that we can still access the store pointer in its own shrinkCache methods, simply pass it there to QQuickPixmapData::removeFromCache. removeFromCache is adjusted to only load the pointer from the global static if it is actually nullptr. Fixes: QTBUG-99192 Pick-to: 6.3 Change-Id: Id439931874455d9bf3d48617ac108e72a22f1676 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Image: make default sourceSize respect DPR for scalable imagesMitch Curtis2021-10-181-6/+10
| | | | | | | | | | | | When loading SVGs where no sourceSize is set, we need to take the DPR into account so that the image isn't upscaled when the DPR is greater than 1. Fixes: QTBUG-58416 Task-number: QTBUG-81018 Pick-to: 6.2 Change-Id: I4356407f63477594c1a057555bf0fb6dabdab415 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* pixmapcache: avoid deadlock when canceling async image loadNick Shaforostov2020-11-181-2/+2
| | | | | | | | was only possible if qml_network is disabled Pick-to: 5.15 Change-Id: If8a8addc0aa5c4c768dd7df3aa4d627f82a78059 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* QQuickImageProvider: Remove reliance on RTTIFabian Kosmale2020-09-011-1/+1
| | | | | | | | | | | | | Using staticCast is unsafe, because in theory you can derive from QQmlImageProviderBase instead of QQuickImageProvider. But using dynamicCast runs into issues, because while Qt needs to be compiled with RTTI, user code does not. We thus turn the baseclass into a QObject so that qobject_cast does work. Fixes: QTBUG-84127 Change-Id: Id40d8a13eaa0101d80bd5742a23996354d70c72a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* webOS: Share images even if cache is falseElvis Lee2020-08-171-1/+34
| | | | | | | | | | | | | | | | | | Regardless Image::cache property, pixmap will be shared between images having same source. Image::cache property had two aspect of internal functionality. 1. Share image instance if source file is same. 2. Store cache for a while even if unreferenced. So we couldn't choose one of them with existing the cache property. In webOS, sharing image instance is quite natural. So by default, the sharing is always supported regardless the cache property. And the property will only cares the 2nd functionality to store cache. Pick-to: 5.15 Change-Id: I68208cf633ce2afd5f086a61dcc77d0f3d0da037 Task-number: QTBUG-83115 Reviewed-by: Risto Avila <risto.avila@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use qHashMulti in qHash(QQuickPixmapKey)Shawn Rutledge2020-08-171-6/+2
| | | | | | | Amends 9cc4568de330e0075c960a5431ecd69a1f9a761d (and others). Change-Id: Ic67a34ffb903d79882d4a74415f52db5a79d30d6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Quick: Clean up some includesUlf Hermann2020-06-041-30/+25
| | | | | | | Uniformly use <...> and sort them by modules. Change-Id: I11cd160783dfb141d8824d635bdc56a63aaee50f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Change qHash return value to size_tFabian Kosmale2020-04-161-1/+1
| | | | | | | | Else on Windows there's a warning: conversion from 'size_t' to 'uint', possible loss of data Change-Id: Ifed4899409a13fed31c206ae1e0f195280ee2925 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>