From 9803a8eb4ef600da46ed524d4b8d329c05574ffe Mon Sep 17 00:00:00 2001 From: DUC ANH HOANG Date: Fri, 19 Jan 2024 11:03:01 +0100 Subject: [PATCH] fix conflict between stadard mode and salome_on_demand mode --- src/LightApp/LightApp_Application.cxx | 11 +++++++---- src/SalomeApprc_utils/SalomeApprc_utils.cxx | 15 +++++++++++---- src/SalomeApprc_utils/SalomeApprc_utils.h | 4 ++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 8d7676bdf..f14da6ff2 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -899,14 +899,14 @@ void LightApp_Application::customize() LightApp_ModuleAction* moduleAction = qobject_cast( action( ModulesListId ) ); // a. regular modules were added in createActions() method // b. here we add custom modules (manually added by the user) - if ( HAS_SALOME_ON_DEMAND ) + if ( HAS_SALOME_ON_DEMAND && QString::compare(getenv("SALOME_ON_DEMAND"),"HIDE", Qt::CaseInsensitive) != 0) { // Update rc file updateSalomeApprc(); QStringList modList = resourceMgr()->stringValue( "launch", "user_modules" ).split( ";", QString::SkipEmptyParts ); foreach ( QString aModule, modList ) - addUserModule( aModule, resourceMgr()->stringValue( "user_modules", aModule ) ); + addUserModule( aModule, resourceMgr()->stringValue( "user_modules", aModule ), true ); } else { @@ -924,9 +924,9 @@ void LightApp_Application::updateSalomeApprc() QString salomemodules(getenv("SALOME_MODULES")); if(salomemodules.isEmpty()) - AddComponents_from_salomeappdir( QDir(extRootDir), resMgr ); + UpdateCompInfo_with_salomeappdir( QDir(extRootDir), resMgr ); else - AddComponents_from_salomemodules(salomemodules, QDir(extRootDir), resMgr); + UpdateCompInfo_with_salomemodules(salomemodules, QDir(extRootDir), resMgr); } /*!On module activation action.*/ @@ -1049,6 +1049,9 @@ void LightApp_Application::onExtAdding() /*Add user module.*/ bool LightApp_Application::addUserModule( const QString& name, const QString& root, bool interactive ) { + if ( name == "KERNEL" || name == "GUI" ) + return false; // skip KERNEL and GUI modules + if ( name.isEmpty() || root.isEmpty() ) return false; diff --git a/src/SalomeApprc_utils/SalomeApprc_utils.cxx b/src/SalomeApprc_utils/SalomeApprc_utils.cxx index 17a8ed214..21b57a2ea 100644 --- a/src/SalomeApprc_utils/SalomeApprc_utils.cxx +++ b/src/SalomeApprc_utils/SalomeApprc_utils.cxx @@ -1,7 +1,11 @@ #include "SalomeApprc_utils.h" -void AddComponents_from_salomeappdir(const QDir& salomeappdir, SUIT_ResourceMgr* ResMgr) +void UpdateCompInfo_with_salomeappdir(const QDir& salomeappdir, SUIT_ResourceMgr* ResMgr) { + // Remove module list and module_root_dirs list + ResMgr->remove("launch", "user_modules"); + ResMgr->remove("user_modules"); + QFileInfoList salomexd_list = salomeappdir.entryInfoList(QStringList() << "*.salomexd",QDir::Files); foreach(QFileInfo filename, salomexd_list) { @@ -46,8 +50,12 @@ void AddComponents_from_salomeappdir(const QDir& salomeappdir, SUIT_ResourceMgr* } } -void AddComponents_from_salomemodules(const QString& salomemodules, const QDir& salomeappdir, SUIT_ResourceMgr* ResMgr) +void UpdateCompInfo_with_salomemodules(const QString& salomemodules, const QDir& salomeappdir, SUIT_ResourceMgr* ResMgr) { + // Remove module list and module_root_dirs list + ResMgr->remove("launch", "user_modules"); + ResMgr->remove("user_modules"); + QRegularExpression sep(":|,"); QStringList components_list = salomemodules.split(sep,QString::SkipEmptyParts); foreach (QString comp, components_list) @@ -61,11 +69,10 @@ void AddComponents_from_salomemodules(const QString& salomemodules, const QDir& AddGuiComponent(comp, comp_root_dir, ResMgr); } - } void AddGuiComponent(const QString& comp, const QString& CompRoot, SUIT_ResourceMgr* ResMgr) { - QStringList CompsResMgr; + QStringList CompsResMgr = ResMgr->stringValue("launch", "user_modules").split(";", QString::SkipEmptyParts); ResMgr->setValue( "user_modules", comp, CompRoot ); CompsResMgr << comp; diff --git a/src/SalomeApprc_utils/SalomeApprc_utils.h b/src/SalomeApprc_utils/SalomeApprc_utils.h index c1dbcd7e8..ae465d05e 100644 --- a/src/SalomeApprc_utils/SalomeApprc_utils.h +++ b/src/SalomeApprc_utils/SalomeApprc_utils.h @@ -11,8 +11,8 @@ const QString ITERACTIVE_EXTCOMPONENT_KEY("salome_interactive"); -void AddComponents_from_salomeappdir(const QDir& salomeappdir, SUIT_ResourceMgr* ResMgr); -void AddComponents_from_salomemodules(const QString& salomemodules, const QDir& salomeappdir, SUIT_ResourceMgr* ResMgr); +void UpdateCompInfo_with_salomeappdir(const QDir& salomeappdir, SUIT_ResourceMgr* ResMgr); +void UpdateCompInfo_with_salomemodules(const QString& salomemodules, const QDir& salomeappdir, SUIT_ResourceMgr* ResMgr); void AddGuiComponent(const QString& comp, const QString& CompRoot, SUIT_ResourceMgr* ResMgr ); #endif \ No newline at end of file -- 2.39.2