From e84c3bdbce884a7e150fff690f0c1a3e0b12ed90 Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 29 Aug 2014 12:43:50 +0000 Subject: [PATCH] refs #441: crash in digue construction --- src/HYDROGUI/HYDROGUI_ChannelOp.cxx | 2 +- src/HYDROGUI/HYDROGUI_Tool.cxx | 17 ++++++++++++++--- src/HYDROGUI/HYDROGUI_Tool.h | 3 ++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index e820deb6..c91f314a 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -109,7 +109,7 @@ void HYDROGUI_ChannelOp::startOperation() } // collect information about existing profiles - QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE ); + QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE, true ); aPanel->setObjectName( anObjectName ); diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx index 75526f52..34f600f5 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -693,16 +694,26 @@ QColor HYDROGUI_Tool::GenerateFillingColor( const Handle(HYDROData_Document)& th } QStringList HYDROGUI_Tool::FindExistingObjectsNames( const Handle(HYDROData_Document)& theDoc, - const ObjectKind theObjectKind ) + const ObjectKind theObjectKind, + bool isCheckValidProfile ) { QStringList aNames; HYDROData_Iterator anIter( theDoc, theObjectKind ); for ( ; anIter.More(); anIter.Next() ) { Handle(HYDROData_Entity) anObject = anIter.Current(); - if( !anObject.IsNull() ) { - aNames.append( anObject->GetName() ); + + bool isOK = !anObject.IsNull(); + + if( isOK && isCheckValidProfile ) + { + Handle_HYDROData_Profile aProfile = Handle_HYDROData_Profile::DownCast( anObject ); + if( !aProfile.IsNull() && !aProfile->IsValid() ) + isOK = false; } + + if( isOK ) + aNames.append( anObject->GetName() ); } return aNames; diff --git a/src/HYDROGUI/HYDROGUI_Tool.h b/src/HYDROGUI/HYDROGUI_Tool.h index e1565e72..d504cc4a 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.h +++ b/src/HYDROGUI/HYDROGUI_Tool.h @@ -335,7 +335,8 @@ public: * \return list of names */ static QStringList FindExistingObjectsNames( const Handle(HYDROData_Document)& theDoc, - const ObjectKind theObjectKind ); + const ObjectKind theObjectKind, + bool isCheckValidProfile = false ); /** * \brief Converts coordinate value to string. -- 2.39.2