From: vsv Date: Wed, 14 Dec 2016 10:57:57 +0000 (+0300) Subject: Issue #1908: Fix bug with wrong identification of Index. Remove process blocking. X-Git-Tag: V_2.7.0~351^2~55^2~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a3d6d4b6a88a62c4906fd36e2e9d30728f006703;p=modules%2Fshaper.git Issue #1908: Fix bug with wrong identification of Index. Remove process blocking. --- diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index e3fa711bf..06dc94894 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -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& 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; +//} diff --git a/src/XGUI/XGUI_DataModel.h b/src/XGUI/XGUI_DataModel.h index 20cfb3aac..1ee25ad29 100644 --- a/src/XGUI/XGUI_DataModel.h +++ b/src/XGUI/XGUI_DataModel.h @@ -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 diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index bedf4f925..0cfa51c9a 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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)