diff --git a/tools/projmgr/include/ProjMgrWorker.h b/tools/projmgr/include/ProjMgrWorker.h index 65c5845ae..769e99e2d 100644 --- a/tools/projmgr/include/ProjMgrWorker.h +++ b/tools/projmgr/include/ProjMgrWorker.h @@ -1113,7 +1113,7 @@ class ProjMgrWorker { } m_contexts.clear(); m_ymlOrderedContexts.clear(); - m_contexts.clear(); + m_processedContexts.clear(); m_contextErrMap.clear(); m_selectedContexts.clear(); m_outputDir.clear(); diff --git a/tools/projmgr/src/ProjMgr.cpp b/tools/projmgr/src/ProjMgr.cpp index 07fc78982..848f8d8e1 100644 --- a/tools/projmgr/src/ProjMgr.cpp +++ b/tools/projmgr/src/ProjMgr.cpp @@ -1291,6 +1291,7 @@ void ProjMgr::Clear() { void ProjMgr::InitSolution(const std::string& csolution, const std::string& activeTargetSet, const bool& updateRte) { Clear(); m_csolutionFile = csolution; + m_worker.SetCsolutionFile(m_csolutionFile); m_rootDir = RteUtils::ExtractFilePath(m_csolutionFile, false); m_updateRteFiles = updateRte; if (activeTargetSet.empty()) { diff --git a/tools/projmgr/src/ProjMgrWorker.cpp b/tools/projmgr/src/ProjMgrWorker.cpp index d2919e04b..5429e53f6 100644 --- a/tools/projmgr/src/ProjMgrWorker.cpp +++ b/tools/projmgr/src/ProjMgrWorker.cpp @@ -455,6 +455,7 @@ bool ProjMgrWorker::InitializeModel() { if(m_kernel) { // kernel is already initialized, clear pdsc map m_kernel->GetPackRegistry()->ClearPdscMap(); + m_model->SetRootFileName(m_csolutionFile); return true; } m_packRoot = GetPackRoot(); @@ -559,7 +560,7 @@ bool ProjMgrWorker::LoadPacks(ContextItem& context) { PrintContextErrors(context.name); return false; } - if (m_loadedPacks.empty() && !LoadAllRelevantPacks()) { + if ((m_loadedPacks.empty() || m_rpcMode) && !LoadAllRelevantPacks()) { return false; } // Filter context specific packs @@ -2254,6 +2255,9 @@ bool ProjMgrWorker::ProcessConfigFiles(ContextItem& context) { bool ProjMgrWorker::CheckConfigPLMFiles(ContextItem& context) { bool error = false; + if (!context.rteActiveProject) { + return error; + } for (const auto& fi : context.rteActiveProject->GetFileInstances()) { // get absolute path to file instance const string file = fs::path(context.cproject->directory).append(fi.second->GetInstanceName()).generic_string(); diff --git a/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp b/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp index a00b48fc5..febd5fef6 100644 --- a/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp @@ -1859,3 +1859,10 @@ TEST_F(ProjMgrWorkerUnitTests, LoadPacksCaseInsensitive) { CrossPlatformUtils::SetEnv("CMSIS_PACK_ROOT", cmsisPackRoot); } + +TEST_F(ProjMgrWorkerUnitTests, CheckConfigPLMFiles_NoRteActiveProject) { + ContextItem context; + context.rteActiveProject = nullptr; + // ensure CheckConfigPLMFiles does not crash when rteActiveProject is not initialized + EXPECT_FALSE(CheckConfigPLMFiles(context)); +}