From 4e20f9beded11d3ea5ee9bb055ad2aff846ecf83 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 26 Apr 2012 10:03:09 +0000 Subject: [PATCH] Fix crash if other view is the same as OCC, but it has no "synchronization" action --- src/OCCViewer/OCCViewer_ViewWindow.cxx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 1c32abc73..26e9ba79d 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -2556,11 +2556,14 @@ void OCCViewer_ViewWindow::synchronizeView( OCCViewer_ViewWindow* viewWindow, in // synchronize target view with source view viewWindow->getViewPort()->synchronize( otherViewWindow->getViewPort() ); viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() ); - otherViewWindow->toolMgr()->action( SynchronizeId )->setData( viewWindow->getId() ); - if ( !otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) { - bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true ); - otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( true ); - otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked ); + QAction* anOtherAcion = otherViewWindow->toolMgr()->action( SynchronizeId ); + if (anOtherAcion) { + anOtherAcion->setData( viewWindow->getId() ); + if ( !anOtherAcion->isChecked() ) { + bool blocked = anOtherAcion->blockSignals( true ); + anOtherAcion->setChecked( true ); + anOtherAcion->blockSignals( blocked ); + } } } } @@ -2570,10 +2573,13 @@ void OCCViewer_ViewWindow::synchronizeView( OCCViewer_ViewWindow* viewWindow, in viewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), otherViewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) ); viewWindow->getViewPort()->synchronize( otherViewWindow->getViewPort() ); viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() ); - if ( otherViewWindow->toolMgr()->action( SynchronizeId )->data().toInt() == viewWindow->getId() && otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) { - bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true ); - otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( false ); - otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked ); + QAction* anOtherAcion = otherViewWindow->toolMgr()->action( SynchronizeId ); + if (anOtherAcion) { + if ( anOtherAcion->data().toInt() == viewWindow->getId() && anOtherAcion->isChecked() ) { + bool blocked = anOtherAcion->blockSignals( true ); + anOtherAcion->setChecked( false ); + anOtherAcion->blockSignals( blocked ); + } } } } -- 2.39.2