From: DUC ANH HOANG Date: Tue, 18 Jul 2023 15:09:41 +0000 (+0200) Subject: update salome env on extension adding X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f8e283841439965274d3e7d09b6ba966704b1fdd;p=modules%2Fgui.git update salome env on extension adding --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 314e2dd24..9db7595f5 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -960,6 +960,7 @@ void LightApp_Application::onExtAdding() // but I didn't compare the performance for each case. PyLockWrapper lck; // acquire GIL PyObjWrapper extensionUnpacker = PyImport_ImportModule((char*)"SalomeOnDemandTK.extension_unpacker"); + PyObjWrapper runSalomeOnDemand = PyImport_ImportModule((char*)"runSalomeOnDemand"); // Loop via selected extensions files foreach(QString path, paths) @@ -988,12 +989,21 @@ void LightApp_Application::onExtAdding() } // Add an extension to GUI + QFileInfo extFileInfo(path); + QString extName = extFileInfo.baseName(); if (moduleAction) { - QFileInfo extFileInfo(path); - QString extName = extFileInfo.baseName(); moduleAction->insertExtension(extName); } + + // Update environment of salome + PyObjWrapper update_env = PyObject_CallMethod( + runSalomeOnDemand, (char*)"set_selext_env", (char*)"ss", extRootDir, extName.toStdString().c_str()); + if (!update_env) + { + SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_FAILED_UPDATE_ENV").arg(extName + "_env.py") ); + continue; + } } // Udate actions only once after all of them were already inserted diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 539ebdbf2..bd3e2155a 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -1247,6 +1247,10 @@ Continue? WRN_FAILED_UNPACK_EXTENSION Failed to unpack a salome extension from file: %1. + + WRN_FAILED_UPDATE_ENV + Failed to update salome environment from file: %1. + WRN_FAILED_REMOVE_EXTENSION Failed to remove a salome extension: %1. diff --git a/src/LightApp/resources/LightApp_msg_fr.ts b/src/LightApp/resources/LightApp_msg_fr.ts index da3460b3b..712f6359a 100644 --- a/src/LightApp/resources/LightApp_msg_fr.ts +++ b/src/LightApp/resources/LightApp_msg_fr.ts @@ -1181,6 +1181,10 @@ Le fichier n'existe pas WRN_FAILED_UNPACK_EXTENSION Échec de la décompression d'une extension salome à partir d'un fichier: %1. + + WRN_FAILED_UPDATE_ENV + Échec de la mise à jour de l'environnement de salome à partir du fichier: %1. + WRN_FAILED_REMOVE_EXTENSION Échec de la suppression d'une extension Salomé: %1.