Skip to content

Commit 72f278b

Browse files
grasci-armbrondani
andauthored
[projmgr] Fix clean-up for successive RPC ConvertSolution calls
Co-authored-by: Daniel Brondani <[email protected]>
1 parent fbf59d7 commit 72f278b

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ class ProjMgrWorker {
11131113
}
11141114
m_contexts.clear();
11151115
m_ymlOrderedContexts.clear();
1116-
m_contexts.clear();
1116+
m_processedContexts.clear();
11171117
m_contextErrMap.clear();
11181118
m_selectedContexts.clear();
11191119
m_outputDir.clear();

tools/projmgr/src/ProjMgr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,7 @@ void ProjMgr::Clear() {
12911291
void ProjMgr::InitSolution(const std::string& csolution, const std::string& activeTargetSet, const bool& updateRte) {
12921292
Clear();
12931293
m_csolutionFile = csolution;
1294+
m_worker.SetCsolutionFile(m_csolutionFile);
12941295
m_rootDir = RteUtils::ExtractFilePath(m_csolutionFile, false);
12951296
m_updateRteFiles = updateRte;
12961297
if (activeTargetSet.empty()) {

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ bool ProjMgrWorker::InitializeModel() {
455455
if(m_kernel) {
456456
// kernel is already initialized, clear pdsc map
457457
m_kernel->GetPackRegistry()->ClearPdscMap();
458+
m_model->SetRootFileName(m_csolutionFile);
458459
return true;
459460
}
460461
m_packRoot = GetPackRoot();
@@ -559,7 +560,7 @@ bool ProjMgrWorker::LoadPacks(ContextItem& context) {
559560
PrintContextErrors(context.name);
560561
return false;
561562
}
562-
if (m_loadedPacks.empty() && !LoadAllRelevantPacks()) {
563+
if ((m_loadedPacks.empty() || m_rpcMode) && !LoadAllRelevantPacks()) {
563564
return false;
564565
}
565566
// Filter context specific packs
@@ -2254,6 +2255,9 @@ bool ProjMgrWorker::ProcessConfigFiles(ContextItem& context) {
22542255

22552256
bool ProjMgrWorker::CheckConfigPLMFiles(ContextItem& context) {
22562257
bool error = false;
2258+
if (!context.rteActiveProject) {
2259+
return error;
2260+
}
22572261
for (const auto& fi : context.rteActiveProject->GetFileInstances()) {
22582262
// get absolute path to file instance
22592263
const string file = fs::path(context.cproject->directory).append(fi.second->GetInstanceName()).generic_string();

tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,3 +1859,10 @@ TEST_F(ProjMgrWorkerUnitTests, LoadPacksCaseInsensitive) {
18591859

18601860
CrossPlatformUtils::SetEnv("CMSIS_PACK_ROOT", cmsisPackRoot);
18611861
}
1862+
1863+
TEST_F(ProjMgrWorkerUnitTests, CheckConfigPLMFiles_NoRteActiveProject) {
1864+
ContextItem context;
1865+
context.rteActiveProject = nullptr;
1866+
// ensure CheckConfigPLMFiles does not crash when rteActiveProject is not initialized
1867+
EXPECT_FALSE(CheckConfigPLMFiles(context));
1868+
}

0 commit comments

Comments
 (0)