From 67a30527691fced3a32ed0442bda35772ceb9d8d Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 24 Jan 2019 09:07:50 +0100 Subject: ModuleLoader: Do not validate property bindings in non-present modules The check for the "not-present" condition was not thorough enough: If a module was successfully loaded, but its validate script failed, then we'd still check property assignments if they happened from within a higher-level module instance. Change-Id: I9d7281eb5603deaa04db008ab9fc340847d83151 Reviewed-by: Joerg Bornemann --- src/lib/corelib/language/moduleloader.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index c4d77ba40..58dab062a 100644 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -464,6 +464,27 @@ private: return; } + // If a module was found but its validate script failed, only the canonical + // module instance will have the "non-present" flag set, so we need to locate it. + if (item->type() == ItemType::ModuleInstance) { + const Item *productItem = nullptr; + for (auto it = m_parentItems.rbegin(); it != m_parentItems.rend(); ++it) { + if ((*it)->type() == ItemType::Product) { + productItem = *it; + break; + } + } + if (productItem) { + for (const Item::Module &m : productItem->modules()) { + if (m.name == m_currentModuleName) { + if (!m.item->isPresentModule()) + return; + break; + } + } + } + } + m_parentItems.push_back(item); for (Item::PropertyMap::const_iterator it = item->properties().constBegin(); it != item->properties().constEnd(); ++it) { -- cgit v1.2.3