]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1900 Fatal error when close study, Issue #1749 Not updating the list "Selected...
authornds <nds@opencascade.com>
Fri, 2 Dec 2016 08:16:21 +0000 (11:16 +0300)
committernds <nds@opencascade.com>
Fri, 2 Dec 2016 08:16:21 +0000 (11:16 +0300)
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/XGUI/XGUI_DataModel.cpp
src/XGUI/XGUI_DataModel.h
src/XGUI/XGUI_Workshop.cpp

index d2e8355f30c8069f77d981de0bca61477cade666..2e8e7a6cb36e6eda6433a2413fdb0210e70e5a63 100755 (executable)
@@ -395,7 +395,40 @@ void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
 {
   activateSelectionAndFilters(true);
 
-  clearSelection();
+  if (!myFeature)
+    return;
+  /// store the selected type
+  AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
+  std::string aType = anAttribute->attributeType();
+  if (aType == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+    aSelectionListAttr->setSelectionType(myTypeCombo->currentText().toStdString());
+  }
+
+  // clear attribute values
+  DataPtr aData = myFeature->data();
+  if (aType == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
+    aSelectionListAttr->clear();
+  }
+  else if (aType == ModelAPI_AttributeRefList::typeId()) {
+    AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
+    aRefListAttr->clear();
+  }
+  else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
+    AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
+    aRefAttrListAttr->clear();
+  }
+
+  // update object is necessary to flush update signal. It leads to objects references map update
+  // and the operation presentation will not contain deleted items visualized as parameters of
+  // the feature.
+  updateObject(myFeature);
+  restoreValue();
+  myWorkshop->setSelected(getAttributeSelection());
+  // may be the feature's result is not displayed, but attributes should be
+  myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
+                            true); /// hope that something is redisplayed by object updated
 }
 
 //********************************************************************
index 1a4efa787c42d32130af361e1dabe685a18b3bcb..3aa3e351c0081f9280502a48bc8671c79675b666 100644 (file)
@@ -63,7 +63,7 @@ ModelAPI_Document* getSubDocument(void* theObj)
 
 // Constructor *************************************************
 XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent),
-  myIsEventsProcessingStopped(false)
+  myIsEventsProcessingBlocked(false)
 {
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
@@ -80,7 +80,7 @@ XGUI_DataModel::~XGUI_DataModel()
 //******************************************************
 void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMessage)
 {
-  if (myIsEventsProcessingStopped)
+  if (myIsEventsProcessingBlocked)
     return;
   DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
   std::string aRootType = myXMLReader->rootType();
@@ -963,3 +963,11 @@ void XGUI_DataModel::rebuildBranch(int theRow, int theCount, const QModelIndex&
     insertRows(theRow, theCount, theParent);
   }
 }
+
+//******************************************************
+bool XGUI_DataModel::blockEventsProcessing(const bool theState)
+{
+  bool aPreviousState = myIsEventsProcessingBlocked;
+  myIsEventsProcessingBlocked = theState;
+  return aPreviousState;
+}
index f3dc27c13b499e4b3c410bc030fba39632892bec..20cfb3aacfffba428b0c8e09842bad2d110a90c0 100644 (file)
@@ -126,7 +126,7 @@ public:
   void setXMLReader(Config_DataModelReader* theReader) { myXMLReader = theReader; }
 
   /// Do not processing anymore events of model loop
-  void stopEventsProcessing() { myIsEventsProcessingStopped = true; }
+  bool blockEventsProcessing(const bool theState);
 
 signals:
   /// Signal about tree had been rebuilt
@@ -165,7 +165,7 @@ private:
 
   Config_DataModelReader* myXMLReader;
 
-  bool myIsEventsProcessingStopped;
+  bool myIsEventsProcessingBlocked;
 };
 
 #endif
\ No newline at end of file
index 8b7aa83a50d0a93cf55595718cca102ef3ab34cd..86265430b2666f8c9333b9b92b76239b69451fdf 100755 (executable)
@@ -2032,10 +2032,12 @@ void XGUI_Workshop::closeDocument()
 
   // data model need not process the document's signals about objects modifications as
   // the document is closed
-  objectBrowser()->dataModel()->stopEventsProcessing();
+  bool isBlocked = objectBrowser()->dataModel()->blockEventsProcessing(true);
 
   SessionPtr aMgr = ModelAPI_Session::get();
   aMgr->closeAll();
+
+  objectBrowser()->dataModel()->blockEventsProcessing(isBlocked);
 }
 
 void XGUI_Workshop::addHistoryMenu(QObject* theObject, const char* theSignal, const char* theSlot)