From cf978fbad63db5197853cc416e736b9d2fc6af70 Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 13 May 2011 09:15:11 +0000 Subject: [PATCH] Fix for the bug "IPAL22486 TC6.3.0: Crash application after hide operation in the plot 2d viewer". --- src/VISU_I/VISU_Table_i.cc | 17 ++++++++++++++++- src/VISU_I/VISU_Tools.cxx | 14 +++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 9dc035e9..63f942b1 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -1004,6 +1004,21 @@ VISU::Storable* VISU::Curve_i::StorableEngine(SALOMEDS::SObject_ptr theSObject, void VISU::Curve_i::RemoveFromStudy() { + + //remove curve from containers + PortableServer::POA_ptr aPOA = GetPOA(); + ContainerSet::ConstIterator it = myContainers.begin(); + for ( ; it != myContainers.end(); it++ ) { + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( (*it).toLatin1().data() ); + if ( aSObject->_is_nil() ) continue; + + CORBA::Object_var anObj = VISU::SObjectToObject( aSObject ); + if ( CORBA::is_nil( anObj ) ) continue; + VISU::Container_i* aContainer = dynamic_cast( VISU::GetServant( anObj.in() ).in() ); + if ( !aContainer ) continue; + aContainer->RemoveCurve(VISU::Curve::_narrow(aPOA->servant_to_reference(this))); + } + struct TRemoveFromStudy: public SALOME_Event { VISU::Curve_i* myRemovable; @@ -1147,7 +1162,7 @@ void VISU::Container_i::RemoveCurve( Curve_ptr theCurve ) */ CORBA::Long VISU::Container_i::GetNbCurves() { - Update(); + // Update(); return myCurves.count(); } /*! diff --git a/src/VISU_I/VISU_Tools.cxx b/src/VISU_I/VISU_Tools.cxx index dca6f107..44249c40 100644 --- a/src/VISU_I/VISU_Tools.cxx +++ b/src/VISU_I/VISU_Tools.cxx @@ -251,7 +251,7 @@ namespace VISU VISU::Container_i* container, int theDisplaying) { - if ( !thePlot ) + if ( !thePlot || !container) return; if ( theDisplaying == VISU::eDisplayOnly ) @@ -260,6 +260,7 @@ namespace VISU thePlot->getCurves( clist ); if ( container->GetNbCurves() > 0 ) { int nbCurves = container->GetNbCurves(); + SetVisibilityState(container->GetEntry(), GetStateByDisplaying(theDisplaying)); for ( int k = 1; k <= nbCurves; k++ ) { VISU::Curve_i* theCurve = container->GetCurve( k ); if ( theCurve && theCurve->IsValid() ) { @@ -370,7 +371,7 @@ namespace VISU if ( updateTable ) { Table_i* aTable = theCurve->getTable(); - if ( aTable ) { + if ( aTable && !(aStudy->visibilityState( aTable->GetEntry().c_str() ) == state) ) { _PTR(SObject) TableSO = aStudy->studyDS()->FindObjectID( aTable->GetEntry() ); if ( TableSO ) { bool isTableVisible = false; @@ -395,6 +396,8 @@ namespace VISU ContainerSet aContainers = theCurve->getContainers(); ContainerSet::ConstIterator it = aContainers.begin(); for ( ; it != aContainers.end(); it++ ) { + //Check that state of container is not set already + if(aStudy->visibilityState(*it) == state) continue; _PTR(SObject) aSObject = aStudy->studyDS()->FindObjectID( (*it).toLatin1().data() ); if ( !aSObject ) continue; bool isContainerDisplayed = false; @@ -445,16 +448,17 @@ namespace VISU SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); if ( !aStudy ) return; - SalomeApp_Module* aModule = dynamic_cast( anApp->module( "VISU" ) ); + SalomeApp_Module* aModule = dynamic_cast( anApp->module( anApp->moduleTitle( "VISU" ) ) ); if ( !aModule ) return; SUIT_ViewManager* aManager = anApp->activeViewManager(); - Qtx::VisibilityState state = ( aManager && aManager->getType() == SPlot2d_Viewer::Type() ) ? + int nbCurves = theContainer->GetNbCurves(); + + Qtx::VisibilityState state = ( aManager && aManager->getType() == SPlot2d_Viewer::Type() && nbCurves > 0 ) ? Qtx::HiddenState : Qtx::UnpresentableState; LightApp_Displayer* aDisplayer = aModule->displayer(); - int nbCurves = theContainer->GetNbCurves(); if ( nbCurves > 0 && aDisplayer ) { for ( int k = 1; k <= nbCurves; k++ ) { VISU::Curve_i* aCurve = theContainer->GetCurve( k ); -- 2.39.2