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