From a08180174b967ecd910dc09a46f457a8a662f406 Mon Sep 17 00:00:00 2001 From: kosta Date: Tue, 14 Feb 2023 10:54:05 +0100 Subject: [PATCH] [bos #32523][EDF] SALOME on Demand GUI. Update ext actions moved outside the loops to prevent building a dependency tree on each iteration. --- src/LightApp/LightApp_Application.cxx | 23 +++++++++++++++++++---- src/LightApp/LightApp_ModuleAction.cxx | 2 -- src/LightApp/LightApp_ModuleAction.h | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index b739a1a52..d0754d3d3 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -833,9 +833,9 @@ void LightApp_Application::createActions() /*!Create actions for installed extensions:*/ void LightApp_Application::addExtensionsActions(LightApp_ModuleAction* moduleAction) { - ASSERT(moduleAction) if (!moduleAction) { + MESSAGE("Couldn't get a moduleAction! Return."); return; } @@ -868,6 +868,9 @@ void LightApp_Application::addExtensionsActions(LightApp_ModuleAction* moduleAct moduleAction->insertExtension(extName); } + + // Udate actions only once after all of them were already inserted + moduleAction->updateExtActions(); } /*! @@ -927,8 +930,18 @@ void LightApp_Application::onExtAdding() // Show dialog to browse a salome extension file QStringList filters = (QStringList() << tr("Salome extension files") + " (*.salomex)" << tr("All files") + " (*)"); QStringList paths = getOpenFileNames(QString(), filters.join(";;"), QString(), desktop()); - if (paths.isEmpty()) // cancelled + if (paths.isEmpty()) + { + MESSAGE("Adding an extension was cancelled."); return; + } + + LightApp_ModuleAction* moduleAction = qobject_cast(action(ModulesListId)); + if (!moduleAction) + { + MESSAGE("Couldn't get a moduleAction! Return."); + return; + } // It should be set on the app start auto extRootDir = getenv(salomeAppDir); @@ -977,15 +990,17 @@ void LightApp_Application::onExtAdding() } // Add an extension to GUI - LightApp_ModuleAction* moduleAction = qobject_cast(action(ModulesListId)); - ASSERT(moduleAction); if (moduleAction) { QFileInfo extFileInfo(path); QString extName = extFileInfo.baseName(); moduleAction->insertExtension(extName); + moduleAction->updateExtActions(); } } + + // Udate actions only once after all of them were already inserted + moduleAction->updateExtActions(); } /*Add user module.*/ diff --git a/src/LightApp/LightApp_ModuleAction.cxx b/src/LightApp/LightApp_ModuleAction.cxx index e7a70c10b..f5f1518c1 100644 --- a/src/LightApp/LightApp_ModuleAction.cxx +++ b/src/LightApp/LightApp_ModuleAction.cxx @@ -443,8 +443,6 @@ void LightApp_ModuleAction::insertExtension(const QString& name) connect(inserted, SIGNAL(triggered()), myMapper, SLOT(map())); myMapper->setMapping(inserted, name); - updateExtActions(); - MESSAGE("An extension's action was inserted"); } diff --git a/src/LightApp/LightApp_ModuleAction.h b/src/LightApp/LightApp_ModuleAction.h index c71524f3b..0b5fbdc3d 100644 --- a/src/LightApp/LightApp_ModuleAction.h +++ b/src/LightApp/LightApp_ModuleAction.h @@ -68,6 +68,7 @@ public: void removeModule( const QString& ); void insertExtension(const QString&); void removeExtension(const QString&); + void updateExtActions(); QString activeModule() const; @@ -94,7 +95,6 @@ signals: private: void update(); void update( QtxComboBox* ); - void updateExtActions(); QAction* active() const; void activate( int, bool = true ); -- 2.39.2