diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-08-29 18:02:10 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-08-31 07:51:11 +0000 |
commit | 89689cac88ffe880942c7acb59fc3374a34cbd6c (patch) | |
tree | 800feec2c017aaf8760426498720950b71b28100 /src/lib/corelib/buildgraph | |
parent | d8c000b6c01787205bd11a475a7b9b0e168451b0 (diff) |
Store product names in ExportedModule
... rather than product pointers. ExportedModule objects can be stored
in Transformers, which potentially outlive the referenced products.
Alternatively, we could update the product pointers during change
tracking, but that would be tedious and error-prone.
[ChangeLog] Fixed possible crash on storing a build graph after re-
resolving.
Change-Id: I09bcf638a17da410198524858eb4c1bda59bebcb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/lib/corelib/buildgraph')
-rw-r--r-- | src/lib/corelib/buildgraph/buildgraph.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/lib/corelib/buildgraph/buildgraph.cpp b/src/lib/corelib/buildgraph/buildgraph.cpp index f12c27ab6..e9767b942 100644 --- a/src/lib/corelib/buildgraph/buildgraph.cpp +++ b/src/lib/corelib/buildgraph/buildgraph.cpp @@ -222,9 +222,25 @@ private: QScriptValue result = engine->newArray(); quint32 idx = 0; const bool exportCase = depType == DependencyType::Exported; - const std::vector<ResolvedProductPtr> &productDeps = (exportCase - ? product->exportedModule.productDependencies - : product->dependencies); + std::vector<ResolvedProductPtr> productDeps; + if (exportCase) { + if (!product->exportedModule.productDependencies.empty()) { + const auto allProducts = product->topLevelProject()->allProducts(); + const auto getProductForName = [&allProducts](const QString &name) { + const auto cmp = [name](const ResolvedProductConstPtr &p) { + return p->uniqueName() == name; + }; + const auto it = std::find_if(allProducts.cbegin(), allProducts.cend(), cmp); + QBS_ASSERT(it != allProducts.cend(), return ResolvedProductPtr()); + return *it; + }; + std::transform(product->exportedModule.productDependencies.cbegin(), + product->exportedModule.productDependencies.cend(), + std::back_inserter(productDeps), getProductForName); + } + } else { + productDeps = product->dependencies; + } for (const ResolvedProductPtr &dependency : qAsConst(productDeps)) { QScriptValue obj = engine->newObject(engine->productPropertyScriptClass()); obj.setPrototype(setupProductScriptValue(static_cast<ScriptEngine *>(engine), |