Skip to content

Commit bf004f1

Browse files
edrioukCopilot
andauthored
Fix crash in LoadPacks RPC call (#2484)
## Fixes <!-- List the issue(s) this PR resolves --> - Open-CMSIS-Pack/vscode-cmsis-solution#250 ## Changes <!-- List the changes this PR introduces --> - clear RTE model and cached list of loaded packs Note: pack registry is not cleared, only new and modified packs get loaded ## Checklist <!-- Put an `x` in the boxes. All tasks must be completed and boxes checked before merging. --> - [ ] 🤖 This change is covered by unit tests (if applicable). - [ ] 🤹 Manual testing has been performed (if necessary). - [ ] 🛡️ Security impacts have been considered (if relevant). - [ ] 📖 Documentation updates are complete (if required). - [ ] 🧠 Third-party dependencies and TPIP updated (if required). --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent c51a8e9 commit bf004f1

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

tools/projmgr/src/ProjMgrRpcServer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ RpcArgs::SuccessResult RpcHandler::LoadPacks(void) {
304304
RpcArgs::SuccessResult result = {false};
305305
m_manager.Clear();
306306
m_solutionLoaded = false;
307+
ProjMgrKernel::Get()->GetGlobalModel()->Clear();
307308
m_worker.InitializeModel();
308309
m_worker.SetLoadPacksPolicy(LoadPacksPolicy::ALL);
309310
result.success = m_worker.LoadAllRelevantPacks();

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool ProjMgrWorker::PushImageOnlyTargetType(const string& targetType, const vect
7474
}
7575
}
7676
CollectionUtils::PushBackUniquely(imageOnlyTargetTypes, targetType);
77-
return true;
77+
return true;
7878
}
7979

8080
void ProjMgrWorker::AddImageOnlyContext() {
@@ -522,6 +522,7 @@ bool ProjMgrWorker::CollectAllRequiredPdscFiles() {
522522
}
523523

524524
bool ProjMgrWorker::LoadAllRelevantPacks() {
525+
m_loadedPacks.clear(); // the list will be updated, it should not contain dangling pointers
525526
// Get required pdsc files
526527
std::list<std::string> pdscFiles;
527528
for (const auto& context : m_selectedContexts) {
@@ -6064,7 +6065,7 @@ bool ProjMgrWorker::CheckPackVerAndCollectRelNotes(std::vector<std::string>& res
60646065

60656066
vector<string> checkPackResults;
60666067
for (const auto& [packId, packInfo] : usedPacks) {
6067-
const string& currentVersion = packInfo.first;
6068+
const string& currentVersion = packInfo.first;
60686069
auto latestPack = latestPacks.find(packId);
60696070
if (latestPack == latestPacks.end()) {
60706071
checkPackResults.push_back(packId + "@" + currentVersion + " (not found in CMSIS pack root or project-specified pack paths)");

0 commit comments

Comments
 (0)