Salome HOME
Suppression of warnings, application launching problems in different cases (on Window...
[modules/shaper.git] / src / XGUI / XGUI_WorkshopListener.cpp
index 370cbe793357c75ec81c2ca422f0a1191ba124e0..ff49e6bfd11d9f0fcfc8afd69ebb938d4dd71e9a 100644 (file)
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_WidgetSelector.h>
 
-#ifdef HAVE_SALOME
 #include <SUIT_Application.h>
 #include <SUIT_Session.h>
-#endif
 
 #include "XGUI_ActionsMgr.h"
 #include "XGUI_Displayer.h"
 #include <iostream>
 #endif
 
+#ifdef WIN32
+#pragma warning(disable : 4189) // for declaration of unused variables (MAYBE_UNUSED)
+#endif
+
 //#define DEBUG_FEATURE_CREATED
 //#define DEBUG_FEATURE_REDISPLAY
 //#define DEBUG_FEATURE_UPDATED
@@ -397,9 +399,13 @@ void XGUI_WorkshopListener::
 void XGUI_WorkshopListener::
   onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
 {
-  SUIT_Application * app = SUIT_Session::session()->activeApplication();
-
-  QVariant aVar = app->property("IsLoadedScript");
+  bool isLoadedScript = false;
+  SUIT_Session* aSession = SUIT_Session::session();
+  if (aSession)
+  {
+    QVariant aVar = aSession->activeApplication()->property("IsLoadedScript");
+    isLoadedScript = !aVar.isNull() && aVar.toBool();
+  }
 
   std::set<ObjectPtr> anObjects = theMsg->objects();
   std::set<ObjectPtr>::const_iterator aIt;
@@ -415,7 +421,7 @@ void XGUI_WorkshopListener::
 
   //bool aHasPart = false;
   bool aDisplayed = false;
-  if (aVar.isNull() || !aVar.toBool()) {
+  if (!isLoadedScript) {
     for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
       ObjectPtr anObject = *aIt;