]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1908: Fix bug with wrong identification of Index. Remove process blocking.
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 14 Dec 2016 10:57:57 +0000 (13:57 +0300)
committernds <nds@opencascade.com>
Thu, 15 Dec 2016 11:36:24 +0000 (14:36 +0300)
src/XGUI/XGUI_DataModel.cpp
src/XGUI/XGUI_DataModel.h
src/XGUI/XGUI_Workshop.cpp

index e3fa711bfd57d29f9f33e5c6c723d34ffa7721ca..06dc948949f04930480947533fdf55602f57dc4f 100644 (file)
@@ -62,8 +62,8 @@ ModelAPI_Document* getSubDocument(void* theObj)
 
 
 // Constructor *************************************************
-XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent),
-  myIsEventsProcessingBlocked(false)
+XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent)//,
+  //myIsEventsProcessingBlocked(false)
 {
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
@@ -80,8 +80,8 @@ XGUI_DataModel::~XGUI_DataModel()
 //******************************************************
 void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMessage)
 {
-  if (myIsEventsProcessingBlocked)
-    return;
+  //if (myIsEventsProcessingBlocked)
+  //  return;
   DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
   std::string aRootType = myXMLReader->rootType();
   std::string aSubType = myXMLReader->subType();
@@ -427,13 +427,14 @@ QVariant XGUI_DataModel::data(const QModelIndex& theIndex, int theRole) const
       int aRow = theIndexRow;
       while (aMissedIdx.contains(aRow))
         aRow++;
-
-      switch (theRole) {
-        case Qt::DisplayRole:
-          return QString(myXMLReader->subFolderName(aRow).c_str()) +
-            QString(" (%1)").arg(rowCount(theIndex));
-        case Qt::DecorationRole:
-          return QIcon(myXMLReader->subFolderIcon(aRow).c_str());
+      if (aRow < myXMLReader->subFoldersNumber()) {
+        switch (theRole) {
+          case Qt::DisplayRole:
+            return QString(myXMLReader->subFolderName(aRow).c_str()) +
+              QString(" (%1)").arg(rowCount(theIndex));
+          case Qt::DecorationRole:
+            return QIcon(myXMLReader->subFolderIcon(aRow).c_str());
+        }
       }
     } else {
       ModelAPI_Object* aObj = (ModelAPI_Object*)theIndex.internalPointer();
@@ -505,8 +506,10 @@ int XGUI_DataModel::rowCount(const QModelIndex& theParent) const
       int aRow = theParent.row();
       while (aMissedIdx.contains(aRow))
         aRow++;
-      std::string aType = myXMLReader->subFolderType(aRow);
-      return aDoc->size(aType);
+      if (aRow < myXMLReader->subFoldersNumber()) {
+        std::string aType = myXMLReader->subFolderType(aRow);
+        return aDoc->size(aType);
+      }
     } else {
       ModelAPI_Object* aObj = (ModelAPI_Object*)theParent.internalPointer();
       // Check for Part feature
@@ -580,10 +583,12 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex &
         QIntList aMissedIdx = missedFolderIndexes(aDoc);
         while (aMissedIdx.contains(aParentRow))
           aParentRow++;
-        std::string aType = myXMLReader->subFolderType(aParentRow);
-        if (theRow < aDoc->size(aType)) {
-          ObjectPtr aObj = aDoc->object(aType, theRow);
-          aIndex = objectIndex(aObj);
+        if (aParentRow < myXMLReader->subFoldersNumber()) {
+          std::string aType = myXMLReader->subFolderType(aParentRow);
+          if (theRow < aDoc->size(aType)) {
+            ObjectPtr aObj = aDoc->object(aType, theRow);
+            aIndex = objectIndex(aObj);
+          }
         }
       } else {
         ModelAPI_Object* aParentObj = (ModelAPI_Object*)theParent.internalPointer();
@@ -965,9 +970,9 @@ void XGUI_DataModel::rebuildBranch(int theRow, int theCount, const QModelIndex&
 }
 
 //******************************************************
-bool XGUI_DataModel::blockEventsProcessing(const bool theState)
-{
-  bool aPreviousState = myIsEventsProcessingBlocked;
-  myIsEventsProcessingBlocked = theState;
-  return aPreviousState;
-}
+//bool XGUI_DataModel::blockEventsProcessing(const bool theState)
+//{
+//  bool aPreviousState = myIsEventsProcessingBlocked;
+//  myIsEventsProcessingBlocked = theState;
+//  return aPreviousState;
+//}
index 20cfb3aacfffba428b0c8e09842bad2d110a90c0..1ee25ad299f23b38bab0ecc45eaf4dab1312dc9c 100644 (file)
@@ -126,7 +126,7 @@ public:
   void setXMLReader(Config_DataModelReader* theReader) { myXMLReader = theReader; }
 
   /// Do not processing anymore events of model loop
-  bool blockEventsProcessing(const bool theState);
+  //bool blockEventsProcessing(const bool theState);
 
 signals:
   /// Signal about tree had been rebuilt
@@ -165,7 +165,7 @@ private:
 
   Config_DataModelReader* myXMLReader;
 
-  bool myIsEventsProcessingBlocked;
+  //bool myIsEventsProcessingBlocked;
 };
 
 #endif
\ No newline at end of file
index bedf4f9254de9729b55efc53cdfad8fd567e729b..0cfa51c9acaa68c4f28de734d3d6ccc0cbc7a5d3 100755 (executable)
@@ -2082,12 +2082,12 @@ void XGUI_Workshop::closeDocument()
 
   // data model need not process the document's signals about objects modifications as
   // the document is closed
-  bool isBlocked = objectBrowser()->dataModel()->blockEventsProcessing(true);
+  //bool isBlocked = objectBrowser()->dataModel()->blockEventsProcessing(true);
 
   SessionPtr aMgr = ModelAPI_Session::get();
   aMgr->closeAll();
 
-  objectBrowser()->dataModel()->blockEventsProcessing(isBlocked);
+  //objectBrowser()->dataModel()->blockEventsProcessing(isBlocked);
 }
 
 void XGUI_Workshop::addHistoryMenu(QObject* theObject, const char* theSignal, const char* theSlot)