From 9a9e7a8215d2d86fc57b8fa2e6370d9762cb2c74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 17 Jan 2014 18:25:50 +0100 Subject: Fix lack of deterministic behavior in moc. Moc should check full scope of any related objects or gadget when it constructs extra data. Change-Id: Ibd1b607a389cd4e788c0916984464cd9103d9c59 Reviewed-by: Olivier Goffart --- src/tools/moc/generator.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/tools/moc') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 2d48c50c83..1af344e908 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -438,6 +438,9 @@ void Generator::generateCode() // Build extra array // QList extraList; + QHash knownExtraMetaObject = knownGadgets; + knownExtraMetaObject.unite(knownQObjectClasses); + for (int i = 0; i < cdef->propertyList.count(); ++i) { const PropertyDef &p = cdef->propertyList.at(i); if (isBuiltinType(p.type)) @@ -453,12 +456,19 @@ void Generator::generateCode() QByteArray unqualifiedScope = p.type.left(s); // The scope may be a namespace for example, so it's only safe to include scopes that are known QObjects (QTBUG-2151) - QHash::ConstIterator scopeIt = knownQObjectClasses.find(unqualifiedScope); - if (scopeIt == knownQObjectClasses.constEnd()) { - scopeIt = knownGadgets.find(unqualifiedScope); - if (scopeIt == knownGadgets.constEnd()) - continue; - } + QHash::ConstIterator scopeIt; + + QByteArray thisScope = cdef->qualified; + do { + int s = thisScope.lastIndexOf("::"); + thisScope = thisScope.left(s); + QByteArray currentScope = thisScope.isEmpty() ? unqualifiedScope : thisScope + "::" + unqualifiedScope; + scopeIt = knownExtraMetaObject.constFind(currentScope); + } while (!thisScope.isEmpty() && scopeIt == knownExtraMetaObject.constEnd()); + + if (scopeIt == knownExtraMetaObject.constEnd()) + continue; + const QByteArray &scope = *scopeIt; if (scope == "Qt") -- cgit v1.2.3