From 252b6c4ee4f04181c1792476d68934591a8475c3 Mon Sep 17 00:00:00 2001 From: grasci <86058054+grasci-arm@users.noreply.github.com> Date: Wed, 6 Dec 2023 12:25:09 +0000 Subject: [PATCH] RTE Model fixes and enhancements (#1240) bugfix in getting component bundle added RteModel parameter to RteKernel::LoadPacks() removed unused NULL_RTE_KERNEL Co-authored-by: Evgueni Driouk --- libs/rtemodel/include/RteKernel.h | 14 +++----------- libs/rtemodel/src/RteComponent.cpp | 2 -- libs/rtemodel/src/RteKernel.cpp | 9 +++++---- libs/rtemodel/test/src/RteModelTest.cpp | 7 +++++++ 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/libs/rtemodel/include/RteKernel.h b/libs/rtemodel/include/RteKernel.h index 9fcc6d402..f25c24b89 100644 --- a/libs/rtemodel/include/RteKernel.h +++ b/libs/rtemodel/include/RteKernel.h @@ -167,12 +167,6 @@ class RteKernel */ virtual CprjFile* GetActiveCprjFile() const; - /** - * @brief getter for "empty" RteKernel object - * @return RteKernel::NULL_RTE_KERNEL - */ - static RteKernel* GetNullKernel() { return &NULL_RTE_KERNEL; } - /** * @brief get installed packs * @param pdscFiles list of installed packs @@ -254,9 +248,11 @@ class RteKernel * @brief load specified pdsc files, but does not insert them in the model * @param pdscFiles list of pathnames to load * @param packs list to receive loaded packs + * @param model RteModel to get state and serve as parent * @return true if successful */ - bool LoadPacks(const std::list& pdscFiles, std::list& packs) const; + bool LoadPacks(const std::list& pdscFiles, std::list& packs, + RteModel* model = nullptr) const; /** * @brief getter for caller information (name & version) @@ -291,9 +287,5 @@ class RteKernel RteCallback* m_rteCallback; XmlItem m_toolInfo; std::string m_cmsisPackRoot; - - // null object to avoid crashes - static RteKernel NULL_RTE_KERNEL; - }; #endif // RteKernel_H diff --git a/libs/rtemodel/src/RteComponent.cpp b/libs/rtemodel/src/RteComponent.cpp index ab224f354..03eeb3b3d 100644 --- a/libs/rtemodel/src/RteComponent.cpp +++ b/libs/rtemodel/src/RteComponent.cpp @@ -1824,8 +1824,6 @@ RteBundle* RteComponentClass::GetSelectedBundle() const { if (!m_selectedBundleName.empty()) { string bundleId = GetSelectedBundleShortID(); - bundleId += "::"; - bundleId += GetName(); return GetTarget()->GetFilteredModel()->GetLatestBundle(bundleId); } return nullptr; diff --git a/libs/rtemodel/src/RteKernel.cpp b/libs/rtemodel/src/RteKernel.cpp index ed43aaac6..dc49589eb 100644 --- a/libs/rtemodel/src/RteKernel.cpp +++ b/libs/rtemodel/src/RteKernel.cpp @@ -37,8 +37,6 @@ static constexpr const char* R822 = "Pack 'path' was not found"; static constexpr const char* R823 = "No PDSC file was found"; static constexpr const char* R824 = "Multiple PDSC files were found"; -RteKernel RteKernel::NULL_RTE_KERNEL; - RteKernel::RteKernel(RteCallback* rteCallback, RteGlobalModel* globalModel) : m_globalModel(globalModel), m_bOwnModel(false), @@ -265,10 +263,13 @@ RtePackage* RteKernel::LoadPack(const string& pdscFile, PackageState packState) return pack; } -bool RteKernel::LoadPacks(const std::list& pdscFiles, std::list& packs) const +bool RteKernel::LoadPacks(const std::list& pdscFiles, std::list& packs, RteModel* model) const { if (!pdscFiles.empty()) { - RteItemBuilder rteItemBuilder(GetGlobalModel(), GetGlobalModel()->GetPackageState()); + if(!model) { + model = GetGlobalModel(); + } + RteItemBuilder rteItemBuilder(model, model->GetPackageState()); unique_ptr xmlTree = CreateUniqueXmlTree(&rteItemBuilder); bool success = xmlTree->SetFileNames(pdscFiles, true); if (success) { diff --git a/libs/rtemodel/test/src/RteModelTest.cpp b/libs/rtemodel/test/src/RteModelTest.cpp index 7722f32a5..395f6358b 100644 --- a/libs/rtemodel/test/src/RteModelTest.cpp +++ b/libs/rtemodel/test/src/RteModelTest.cpp @@ -366,6 +366,13 @@ TEST_F(RteModelPrjTest, LoadCprj) { RteTarget* activeTarget = activeCprjProject->GetActiveTarget(); ASSERT_NE(activeTarget, nullptr); + + auto componentClass = activeTarget->GetComponentClass("RteTestBundle"); + ASSERT_NE(componentClass, nullptr); + RteBundle* bundle = componentClass->GetSelectedBundle(); + ASSERT_NE(bundle, nullptr); + EXPECT_EQ(bundle->GetCbundleName(), componentClass->GetSelectedBundleName()); + map depResults; RteItem::ConditionResult res = activeTarget->GetDepsResult(depResults, activeTarget); EXPECT_EQ(res, RteItem::FULFILLED);