From e54f713ad9cdd5d164f7415a8a9adf3ce337056d Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 7 Dec 2016 09:23:08 +0300 Subject: [PATCH] Issue #1798 Error when loading a dumped script --- src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp index f2bd66cae..15027a581 100644 --- a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp +++ b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp @@ -468,12 +468,16 @@ void SHAPERGUI_SalomeViewer::Zfitall() if (!mySelector || !mySelector->viewer()) return; SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager(); - OCCViewer_ViewFrame* aView = dynamic_cast(aMgr->getActiveView()); - if (aView) { - OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW); - Handle(V3d_View) aView3d = aWnd->getViewPort()->getView(); - aView3d->ZFitAll(); - if (aView3d->Depth() < 0.1) - aView3d->DepthFitAll(); + /// WORKAROUND for issue #1798. SUIT_ViewManager::closeAllViews() should nullify myActiveView + /// As a result, we need to check views count in manager + if (aMgr->getViews().size() > 0) { + OCCViewer_ViewFrame* aView = dynamic_cast(aMgr->getActiveView()); + if (aView) { + OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW); + Handle(V3d_View) aView3d = aWnd->getViewPort()->getView(); + aView3d->ZFitAll(); + if (aView3d->Depth() < 0.1) + aView3d->DepthFitAll(); + } } } \ No newline at end of file -- 2.39.2