From: vsv Date: Fri, 22 May 2015 07:38:29 +0000 (+0300) Subject: Avoid crash on load document X-Git-Tag: V_1.2.0~118 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c2332acf79ff3133e546894a44ae4d98274870f8;p=modules%2Fshaper.git Avoid crash on load document --- diff --git a/src/PartSet/PartSet_DocumentDataModel.cpp b/src/PartSet/PartSet_DocumentDataModel.cpp index cd12d6ed9..50bae54ac 100644 --- a/src/PartSet/PartSet_DocumentDataModel.cpp +++ b/src/PartSet/PartSet_DocumentDataModel.cpp @@ -333,7 +333,10 @@ QVariant PartSet_DocumentDataModel::headerData(int theSection, Qt::Orientation t int PartSet_DocumentDataModel::rowCount(const QModelIndex& theParent) const { - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); + SessionPtr aSession = ModelAPI_Session::get(); + if (!aSession->hasModuleDocument()) + return 0; + DocumentPtr aRootDoc = aSession->moduleDocument(); if (!theParent.isValid()) { // Size of external models int aVal = historyOffset(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 9da339e98..8774bbf91 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -828,7 +828,6 @@ void XGUI_Workshop::onOpen() } else if (anAnswer == QMessageBox::Cancel) { return; } - aSession->closeAll(); myCurrentDir = ""; } @@ -844,6 +843,7 @@ void XGUI_Workshop::onOpen() } QApplication::setOverrideCursor(Qt::WaitCursor); myIsLoadingData = true; + aSession->closeAll(); aSession->load(myCurrentDir.toLatin1().constData()); myObjectBrowser->rebuildDataTree(); displayAllResults();