]> 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)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 14 Dec 2016 10:57:57 +0000 (13:57 +0300)
src/XGUI/XGUI_DataModel.cpp
src/XGUI/XGUI_DataModel.h
src/XGUI/XGUI_Workshop.cpp

index 3aa3e351c0081f9280502a48bc8671c79675b666..46ff42386bc4fd97114f45a6e01115e3f00be928 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 d80fcaf25a929030e72bbddbbc4f21c88df6a5db..615aa3579fbfc254df8484041a9feca34b67c023 100755 (executable)
@@ -2080,12 +2080,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)