From b7abf2b1011c2babecbe7b4289e9e23d1001b1ff Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 16 Jul 2014 11:29:59 +0400 Subject: [PATCH] Bug fixing after changes of ModelAPI --- src/XGUI/XGUI_ContextMenuMgr.cpp | 10 ++++------ src/XGUI/XGUI_PartDataModel.cpp | 3 ++- src/XGUI/XGUI_Workshop.cpp | 16 ++++++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 62d3ebe62..0cfd7e493 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -108,24 +108,22 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const if (aObject) { ResultPartPtr aPart = boost::dynamic_pointer_cast(aObject); if (aPart) { - DocumentPtr aFeaDoc = aPart->partDoc(); - if (aMgr->currentDocument() == aFeaDoc) + if (aMgr->currentDocument() == aPart->partDoc()) aMenu->addAction(action("DEACTIVATE_PART_CMD")); else aMenu->addAction(action("ACTIVATE_PART_CMD")); } else { ResultPtr aResult = boost::dynamic_pointer_cast(aObject); if (aResult) { - aMenu->addAction(action("EDIT_CMD")); - XGUI_Displayer* aDisplayer = myWorkshop->displayer(); if (aDisplayer->isVisible(aResult)) aMenu->addAction(action("HIDE_CMD")); else aMenu->addAction(action("SHOW_CMD")); } else { - FeaturePtr aResult = boost::dynamic_pointer_cast(aObject); - if (aResult) { + FeaturePtr aFeature = boost::dynamic_pointer_cast(aObject); + if (aFeature) { + aMenu->addAction(action("EDIT_CMD")); aMenu->addAction(action("DELETE_CMD")); } } diff --git a/src/XGUI/XGUI_PartDataModel.cpp b/src/XGUI/XGUI_PartDataModel.cpp index 82f8c132b..5a5af7888 100644 --- a/src/XGUI/XGUI_PartDataModel.cpp +++ b/src/XGUI/XGUI_PartDataModel.cpp @@ -390,7 +390,8 @@ DocumentPtr XGUI_PartDataModel::partDocument() const { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId); - return aObject->document(); + ResultPartPtr aPart = boost::dynamic_pointer_cast(aObject); + return aPart->partDoc(); } ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 4671c0d50..084a800c9 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -854,12 +854,16 @@ void XGUI_Workshop::changeCurrentDocument(ObjectPtr theObj) { PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); if (theObj) { - DocumentPtr aPartDoc = theObj->document(); - if (aPartDoc) - aMgr->setCurrentDocument(aPartDoc); - } else { - aMgr->setCurrentDocument(aMgr->rootDocument()); - } + ResultPartPtr aPart = boost::dynamic_pointer_cast(theObj); + if (aPart) { + DocumentPtr aPartDoc = aPart->partDoc(); + if (aPartDoc) { + aMgr->setCurrentDocument(aPartDoc); + return; + } + } + } + aMgr->setCurrentDocument(aMgr->rootDocument()); } //****************************************************** -- 2.39.2