Salome HOME
Issue #1900: Clear cashed index on document closing
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 29 Dec 2016 10:03:08 +0000 (13:03 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 29 Dec 2016 10:03:21 +0000 (13:03 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_DataModel.cpp

index fc24193b82ff0761aa562a19673e74f7089ed40d..a092bbe686d5a0265e7617948dc0478b7a23af54 100755 (executable)
@@ -578,6 +578,7 @@ bool PartSet_Module::isSketchNeutralPointActivated() const
 
 void PartSet_Module::closeDocument()
 {
+  myActivePartIndex = QModelIndex();
   clearViewer();
 }
 
@@ -1229,12 +1230,12 @@ void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMess
 
     SessionPtr aMgr = ModelAPI_Session::get();
     DocumentPtr aActiveDoc = aMgr->activeDocument();
-    if (aActivePartIndex.isValid())
-      aTreeView->setExpanded(aActivePartIndex, false);
+    if (myActivePartIndex.isValid())
+      aTreeView->setExpanded(myActivePartIndex, false);
     XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
-    aActivePartIndex = aDataModel->documentRootIndex(aActiveDoc);
-    if (aActivePartIndex.isValid())
-      aTreeView->setExpanded(aActivePartIndex, true);
+    myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc);
+    if (myActivePartIndex.isValid())
+      aTreeView->setExpanded(myActivePartIndex, true);
 
     aLabel->setPalette(aPalet);
     aWorkshop->updateCommandStatus();
index 06fdf458c2017b925abb7b68151da9b3c9fee982..91338d132c19fe5a108eabf18dafc273a53a86b8 100755 (executable)
@@ -424,7 +424,7 @@ private:
   /// backup of the visible state to restore them by operation stop
   QMap<PartSet_Tools::ConstraintVisibleState, bool> myHasConstraintShown;
 
-  QModelIndex aActivePartIndex;
+  QModelIndex myActivePartIndex;
 };
 
 #endif
index 5a628eefee0f5e5396b7bab318185e78e8c832a4..6bf061dcf0365e440e8d2818b97e7bcf345fbc82 100644 (file)
@@ -77,6 +77,7 @@ XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParen
 
 XGUI_DataModel::~XGUI_DataModel()
 {
+  clear();
 }
 
 //******************************************************
@@ -317,7 +318,8 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
 //******************************************************
 void XGUI_DataModel::clear()
 {
-
+  beginResetModel();
+  endResetModel();
 }
 
 //******************************************************