Ensure cached moduleName matches when avoiding conversion
authorMatthew Vogt <matthew.vogt@nokia.com>
Fri, 25 May 2012 00:01:21 +0000 (10:01 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 25 May 2012 00:13:38 +0000 (02:13 +0200)
Multiple plugins can have their module strings loaded at the same
logical address, so simple comparison of the string addresses fails
between multiple plugins.

Change-Id: If0bcbaaafa595e9581db1f3e480f7b1bffbae101
Reviewed-by: Martin Jones <martin.jones@nokia.com>
src/qml/qml/qqmlmetatype.cpp

index 87c39b1..416caa9 100644 (file)
@@ -200,7 +200,9 @@ static QHashedString moduletoUtf8(const char *module)
     static const char *lastModule = 0;
     static QHashedString lastModuleStr;
 
-    if (lastModule != module) {
+    // Separate plugins may have different strings at the same address
+    QHashedCStringRef currentModule(module, ::strlen(module));
+    if ((lastModule != module) || (lastModuleStr.hash() != currentModule.hash())) {
         lastModuleStr = QString::fromUtf8(module);
         lastModuleStr.hash();
         lastModule = module;