diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp index 56b15e53676f6c25456a5c91eaf03480f9f1fdcc..d7498c3e8a32d8585a4693ccb06ed44fb7ec7f91 100644 --- a/src/libs/qmljs/qmljslink.cpp +++ b/src/libs/qmljs/qmljslink.cpp @@ -60,6 +60,8 @@ void LinkImports::linkImports(Bind *bind, const QList<Bind *> &binds) path += it->import->fileName->asString(); path = QDir::cleanPath(path); + ObjectValue *importNamespace = 0; + foreach (Bind *otherBind, binds) { Document::Ptr otherDoc = otherBind->_doc; QFileInfo otherFileInfo(otherDoc->fileName()); @@ -70,11 +72,9 @@ void LinkImports::linkImports(Bind *bind, const QList<Bind *> &binds) if (!directoryImport && !fileImport) continue; - ObjectValue *importInto = bind->_typeEnvironment; - if (directoryImport && it->import->importId) { - ObjectValue *namespaceObject = bind->_interp->newObject(/*prototype =*/0); - importInto->setProperty(it->import->importId->asString(), namespaceObject); - importInto = namespaceObject; + if (directoryImport && it->import->importId && !importNamespace) { + importNamespace = bind->_interp->newObject(/*prototype =*/0); + bind->_typeEnvironment->setProperty(it->import->importId->asString(), importNamespace); } QString targetName; @@ -84,6 +84,10 @@ void LinkImports::linkImports(Bind *bind, const QList<Bind *> &binds) targetName = componentName(otherFileInfo.fileName()); } + ObjectValue *importInto = bind->_typeEnvironment; + if (importNamespace) + importInto = importNamespace; + importInto->setProperty(targetName, otherBind->_rootObjectValue); } }