From ccd69247eaa6289bc31115f863ba4737b14fe34e Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Thu, 3 May 2012 09:55:48 +1000 Subject: [PATCH] Add a static flag to avoid unnecessary QQmlData::init() calls Change-Id: I0b38753bfaf2d1e22ab67977001b946a686b0f56 Reviewed-by: Matthew Vogt --- src/qml/qml/qqmldata_p.h | 15 ++++++++++----- src/qml/qml/qqmlengine.cpp | 10 +--------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 0686830..e97bbb1 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -83,14 +83,19 @@ public: bindings(0), signalHandlers(0), nextContextObject(0), prevContextObject(0), bindingBitsSize(0), bindingBits(0), lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0), v8objectid(0), propertyCache(0), guards(0), extendedData(0) { + init(); } static inline void init() { - QAbstractDeclarativeData::destroyed = destroyed; - QAbstractDeclarativeData::parentChanged = parentChanged; - QAbstractDeclarativeData::objectNameChanged = objectNameChanged; - QAbstractDeclarativeData::signalEmitted = signalEmitted; - QAbstractDeclarativeData::receivers = receivers; + static bool initialized = false; + if (!initialized) { + initialized = true; + QAbstractDeclarativeData::destroyed = destroyed; + QAbstractDeclarativeData::parentChanged = parentChanged; + QAbstractDeclarativeData::objectNameChanged = objectNameChanged; + QAbstractDeclarativeData::signalEmitted = signalEmitted; + QAbstractDeclarativeData::receivers = receivers; + } } static void destroyed(QAbstractDeclarativeData *, QObject *); diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 5ae35f9..7cb766b 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -468,15 +468,6 @@ int QQmlData::endpointCount(int index) return count; } -namespace { - class QQmlDataInitializer { - public: - QQmlDataInitializer() { - QQmlData::init(); - } - } _initializer; -} - void QQmlEnginePrivate::init() { Q_Q(QQmlEngine); @@ -485,6 +476,7 @@ void QQmlEnginePrivate::init() if (firstTime) { qmlRegisterType("QML", 1, 0, "Component"); + QQmlData::init(); firstTime = false; } -- 2.7.4