From ef8e2cd85d380ee9f19cb6642c11e9f7c9fc3a7d Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 22 Sep 2014 14:09:41 +0200 Subject: Allow multiple cached qml unit registration functions Only few will be necessary, but this allows for greater flexibility at run-time. Change-Id: Ia03abeb6296a5dee97544209c578dc2974af7cbc Reviewed-by: Lars Knoll --- src/qml/qml/qqmlmetatype.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/qml/qml/qqmlmetatype.cpp') diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index c09ab69424..d20fe72d09 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -98,7 +98,7 @@ struct QQmlMetaTypeData QBitArray lists; QList parentFunctions; - QQmlPrivate::QmlUnitCacheLookupFunction lookupCachedQmlUnit; + QVector lookupCachedQmlUnit; QSet protectedNamespaces; @@ -135,7 +135,6 @@ static uint qHash(const QQmlMetaTypeData::VersionedUri &v) } QQmlMetaTypeData::QQmlMetaTypeData() - : lookupCachedQmlUnit(0) { } @@ -1347,7 +1346,7 @@ int registerQmlUnitCacheHook(const QQmlPrivate::RegisterQmlUnitCacheHook &hookRe qFatal("qmlRegisterType(): Cannot mix incompatible QML versions."); QWriteLocker lock(metaTypeDataLock()); QQmlMetaTypeData *data = metaTypeData(); - data->lookupCachedQmlUnit = hookRegistration.lookupCachedQmlUnit; + data->lookupCachedQmlUnit << hookRegistration.lookupCachedQmlUnit; return 0; } @@ -1877,8 +1876,11 @@ const QQmlPrivate::CachedQmlUnit *QQmlMetaType::findCachedCompilationUnit(const { QReadLocker lock(metaTypeDataLock()); QQmlMetaTypeData *data = metaTypeData(); - if (data->lookupCachedQmlUnit) - return data->lookupCachedQmlUnit(uri); + for (QVector::ConstIterator it = data->lookupCachedQmlUnit.constBegin(), end = data->lookupCachedQmlUnit.constEnd(); + it != end; ++it) { + if (const QQmlPrivate::CachedQmlUnit *unit = (*it)(uri)) + return unit; + } return 0; } -- cgit v1.2.3