From 75ca259e523973b674b6a978d7c2284f5dc1ef9f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 2 Jul 2021 10:28:57 +0200 Subject: Completely cache the result of qmldir searches Change-Id: Ib6a41c8d20b1443d8d4296190c007f4627086602 Reviewed-by: Fabian Kosmale (cherry picked from commit c1d55e0de6cc26a0b7473a9e5c49753a8ac27d14) Reviewed-by: Jaeyoon Jung Reviewed-by: Andrei Golubev --- src/qml/qml/qqmlimport_p.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/qml/qml/qqmlimport_p.h b/src/qml/qml/qqmlimport_p.h index bbf279780d..f92c2f7c38 100644 --- a/src/qml/qml/qqmlimport_p.h +++ b/src/qml/qml/qqmlimport_p.h @@ -286,8 +286,11 @@ QQmlImportDatabase::LocalQmldirResult QQmlImportDatabase::locateLocalQmldir( QmldirCache *cache = cacheHead; while (cache) { if (cache->version == version) { - if (cache->qmldirFilePath.isEmpty()) - return QmldirNotFound; + if (cache->qmldirFilePath.isEmpty()) { + return cache->qmldirPathUrl.isEmpty() + ? QmldirNotFound + : QmldirInterceptedToRemote; + } if (callback(cache->qmldirFilePath, cache->qmldirPathUrl)) return QmldirFound; result = QmldirRejected; @@ -361,10 +364,15 @@ QQmlImportDatabase::LocalQmldirResult QQmlImportDatabase::locateLocalQmldir( } // Nothing found? Add an empty cache entry to signal that for further requests. - if (result == QmldirNotFound) { + if (result == QmldirNotFound || result == QmldirInterceptedToRemote) { QmldirCache *cache = new QmldirCache; cache->version = version; cache->next = cacheHead; + if (result == QmldirInterceptedToRemote) { + // The actual value doesn't matter as long as it's not empty. + // We only use it to discern QmldirInterceptedToRemote from QmldirNotFound above. + cache->qmldirPathUrl = QStringLiteral("intercepted"); + } qmldirCache.insert(uri, cache); } -- cgit v1.2.3