From a1c9fc93b94bb6ec26476b347f55479def13118a Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 9 Jun 2020 17:49:43 +0300 Subject: [PATCH] Avoid ciclik call of addModule() method on activation of Shaper module --- src/CAM/CAM_Application.cxx | 2 ++ src/CAM/CAM_Application.h | 3 +++ src/LightApp/LightApp_Application.cxx | 22 +++++++++++++--------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 9612c4e4d..aeabb7a47 100644 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -417,6 +417,7 @@ bool CAM_Application::activateModule( const QString& modName ) bool res = false; if ( !modName.isEmpty() ) { + myActvatingModule = modName; CAM_Module* mod = module( modName ); if ( !mod ) mod = loadModule( modName ); @@ -424,6 +425,7 @@ bool CAM_Application::activateModule( const QString& modName ) if ( mod ) res = activateModule( mod ); + myActvatingModule = QString(); } else res = activateModule( 0 ); diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index b0b69d3f6..0dae7d11f 100644 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -94,6 +94,8 @@ protected: virtual bool abortAllOperations(); + QString actvatingModule() const { return myActvatingModule; } + private: void readModuleList(); @@ -111,6 +113,7 @@ private: static ModuleInfoList myInfoList; //!< modules info list bool myAutoLoad; //!< auto loading flag bool myBlocked; //!< "blocked" flag, internal usage + QString myActvatingModule; //!< Name of currently activating module. }; #ifdef WIN32 diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index baf53032e..14a63145c 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -4958,20 +4958,24 @@ void LightApp_Application::onDesktopMessage( const QString& message ) } else if ( message.toLower().startsWith("register_module_in_study" ) ) { QString moduleName = message.split( sectionSeparator ).last(); - CAM_Module* mod = module( moduleName ); - if ( !mod ) - mod = module( moduleTitle( moduleName ) ); - if ( !mod ) { - mod = loadModule( moduleName ); - if ( !mod ) - mod = loadModule( moduleTitle( moduleName) ); - if ( mod ) { + // Check name of current activating module name in order to avoid ciclik + // call because of messages + if (actvatingModule().isNull()) { + CAM_Module* mod = module(moduleName); + if (!mod) + mod = module(moduleTitle(moduleName)); + if (!mod) { + mod = loadModule(moduleName); + if (!mod) + mod = loadModule(moduleTitle(moduleName)); + if (mod) { addModule(mod); CAM_Study* anActiveStudy = dynamic_cast(activeStudy()); if (anActiveStudy) mod->connectToStudy(anActiveStudy); } - } + } + } } else { QStringList data = message.split( sectionSeparator ); -- 2.39.2