From 0c316ec74fd5f46832756cb6304fd644d017cc2a Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 17 Dec 2021 00:43:45 +0300 Subject: [PATCH] bos #26805: regressions in tests Eliminate SIGSEGV --- src/ModelHighAPI/CMakeLists.txt | 2 ++ src/ModelHighAPI/ModelHighAPI_Services.cpp | 5 ++++- src/ModuleBase/ModuleBase_Tools.cpp | 9 +++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ModelHighAPI/CMakeLists.txt b/src/ModelHighAPI/CMakeLists.txt index 2d7a4917f..07adac9db 100644 --- a/src/ModelHighAPI/CMakeLists.txt +++ b/src/ModelHighAPI/CMakeLists.txt @@ -58,6 +58,7 @@ SET(PROJECT_LIBRARIES Locale ModelAPI ModelGeomAlgo + ModuleBase ) ADD_DEFINITIONS(-DMODELHIGHAPI_EXPORTS -DWNT) @@ -87,6 +88,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/Locale ${PROJECT_SOURCE_DIR}/src/ModelAPI ${PROJECT_SOURCE_DIR}/src/ModelGeomAlgo + ${PROJECT_SOURCE_DIR}/src/ModuleBase ${PROJECT_SOURCE_DIR}/src/PartSetPlugin ${OpenCASCADE_INCLUDE_DIR} ) diff --git a/src/ModelHighAPI/ModelHighAPI_Services.cpp b/src/ModelHighAPI/ModelHighAPI_Services.cpp index 09dea983c..763798c8b 100644 --- a/src/ModelHighAPI/ModelHighAPI_Services.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Services.cpp @@ -26,6 +26,8 @@ #include #include +#include + #include #include @@ -106,8 +108,9 @@ void begin() aNbTransactions = aNbUndo; ++aTransactionID; } + static std::string anOperationPrefix(ModuleBase_Tools::translate("", "Operation").toStdString()); std::ostringstream aTransactionName; - aTransactionName << "Operation_" << aTransactionID; + aTransactionName << anOperationPrefix << "_" << aTransactionID; ModelAPI_Session::get()->startOperation(aTransactionName.str()); } diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 1b5bfc9a3..15b389749 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -135,8 +135,13 @@ namespace ModuleBase_Tools { #if HAVE_SALOME // If the python script is being loaded now, the preferences should be used // to display the required object - SUIT_Application * app = SUIT_Session::session()->activeApplication(); - QVariant aVar = app->property("IsLoadedScript"); + SUIT_Session* aSession = SUIT_Session::session(); + if (!aSession) + return; + SUIT_Application * anApp = aSession->activeApplication(); + if (!anApp) + return; + QVariant aVar = anApp->property("IsLoadedScript"); if (!aVar.isNull() && aVar.toBool()) { DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); int aSize = aRootDoc->size(ModelAPI_ResultPart::group()); -- 2.39.2