Salome HOME
Add tools
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetValidated.cpp
index 20b33095f153e38255c8eb0db83eb4a6b8d85716..55abdb5035e40020379be97f8b0697d81c85d337 100644 (file)
@@ -25,7 +25,7 @@ ModuleBase_WidgetValidated::ModuleBase_WidgetValidated(QWidget* theParent,
                                                        const Config_WidgetAPI* theData,
                                                        const std::string& theParentId)
 : ModuleBase_ModelWidget(theParent, theData, theParentId),
-  myWorkshop(theWorkshop)
+  myWorkshop(theWorkshop), myIsInValidate(false)
 {
 }
 
@@ -60,6 +60,18 @@ ObjectPtr ModuleBase_WidgetValidated::findPresentedObject(const AISObjectPtr& th
   return myPresentedObject;
 }
 
+//********************************************************************
+void ModuleBase_WidgetValidated::storeAttributeValue()
+{
+  myIsInValidate = true;
+}
+
+//********************************************************************
+void ModuleBase_WidgetValidated::restoreAttributeValue(const bool theValid)
+{
+  myIsInValidate = false;
+}
+
 //********************************************************************
 bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrs& thePrs)
 {
@@ -89,11 +101,14 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrs& th
     if (!isActivated)
       activateFilters(true);
 
-    const SelectMgr_ListOfFilter& aFilters = myWorkshop->viewer()->AISContext()->Filters();
-    SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
-    for (; anIt.More() && aValid; anIt.Next()) {
-      Handle(SelectMgr_Filter) aFilter = anIt.Value();
-      aValid = aFilter->IsOk(anOwner);
+    Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+    if (!aContext.IsNull()) {
+      const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
+      SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
+      for (; anIt.More() && aValid; anIt.Next()) {
+        Handle(SelectMgr_Filter) aFilter = anIt.Value();
+        aValid = aFilter->IsOk(anOwner);
+      }
     }
     if (!isActivated)
       activateFilters(false);