@@ -536,30 +536,28 @@ std::pair<std::shared_ptr<Assembly>, std::vector<std::string>> Assembly::fromJSO
536
536
" Member 'sourceList' may only be present in the root JSON object."
537
537
);
538
538
539
- std::vector<std::string> sourceList ;
539
+ std::vector<std::string> parsedSourceList ;
540
540
if (_json.isMember (" sourceList" ))
541
541
{
542
542
solAssert (_level == 0 );
543
543
solAssert (_sourceList.empty ());
544
544
for (Json::Value const & sourceName: _json[" sourceList" ])
545
545
{
546
546
solRequire (
547
- std::find (sourceList .begin (), sourceList .end (), sourceName.asString ()) == sourceList .end (),
547
+ std::find (parsedSourceList .begin (), parsedSourceList .end (), sourceName.asString ()) == parsedSourceList .end (),
548
548
AssemblyImportException,
549
549
" Items in 'sourceList' array are not unique."
550
550
);
551
- sourceList .emplace_back (sourceName.asString ());
551
+ parsedSourceList .emplace_back (sourceName.asString ());
552
552
}
553
553
}
554
- else
555
- sourceList = _sourceList;
556
554
557
555
solRequire (_json.isMember (" .code" ), AssemblyImportException, " Member '.code' is missing." );
558
556
solRequire (_json[" .code" ].isArray (), AssemblyImportException, " Member '.code' is not an array." );
559
557
for (Json::Value const & codeItem: _json[" .code" ])
560
558
solRequire (codeItem.isObject (), AssemblyImportException, " The '.code' array contains an item that is not an object." );
561
559
562
- result->importAssemblyItemsFromJSON (_json[" .code" ], sourceList );
560
+ result->importAssemblyItemsFromJSON (_json[" .code" ], _level == 0 ? parsedSourceList : _sourceList );
563
561
564
562
if (_json[" .auxdata" ])
565
563
{
@@ -608,8 +606,9 @@ std::pair<std::shared_ptr<Assembly>, std::vector<std::string>> Assembly::fromJSO
608
606
609
607
if (result->m_subs .size () <= index)
610
608
result->m_subs .resize (index + 1 );
611
- std::shared_ptr<Assembly> subassembly ( Assembly::fromJSON (dataItem, sourceList , _level + 1 ). first );
609
+ auto [ subassembly, emptySourceList] = Assembly::fromJSON (dataItem, _level == 0 ? parsedSourceList : _sourceList , _level + 1 );
612
610
solAssert (subassembly);
611
+ solAssert (emptySourceList.empty ());
613
612
result->m_subs [index] = subassembly;
614
613
}
615
614
else
@@ -618,7 +617,7 @@ std::pair<std::shared_ptr<Assembly>, std::vector<std::string>> Assembly::fromJSO
618
617
}
619
618
if (_level == 0 )
620
619
result->updatePaths ();
621
- return std::make_pair (result, sourceList );
620
+ return std::make_pair (result, _level == 0 ? parsedSourceList : std::vector<std::string>{} );
622
621
}
623
622
624
623
void Assembly::updatePaths (std::vector<Assembly*> const & _parents, std::vector<size_t > const & _absolutePathFromRoot)
0 commit comments