From eb4b7993df5270eb77bf5b6b133eb01b950608d4 Mon Sep 17 00:00:00 2001 From: adv Date: Fri, 17 Jan 2014 07:03:29 +0000 Subject: [PATCH] Protection from crash. --- src/HYDROData/HYDROData_Obstacle.cxx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index 2b8c7cb6..22fcb0f5 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -143,9 +143,13 @@ QString HYDROData_Obstacle::GetFilePath() const { QString aRes; - Handle(TDataStd_AsciiString) anAsciiStr; - if ( myLab.FindChild( DataTag_FilePath ).FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) ) - aRes = QString( anAsciiStr->Get().ToCString() ); + TDF_Label aLabel = myLab.FindChild( DataTag_FilePath, false ); + if ( !aLabel.IsNull() ) + { + Handle(TDataStd_AsciiString) anAsciiStr; + if ( aLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) ) + aRes = QString( anAsciiStr->Get().ToCString() ); + } return aRes; } @@ -160,9 +164,13 @@ QString HYDROData_Obstacle::GetGeomObjectEntry() const { QString aRes; - Handle(TDataStd_AsciiString) anAsciiStr; - if ( myLab.FindChild( DataTag_GeomObjectEntry ).FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) ) - aRes = QString( anAsciiStr->Get().ToCString() ); + TDF_Label aLabel = myLab.FindChild( DataTag_GeomObjectEntry, false ); + if ( !aLabel.IsNull() ) + { + Handle(TDataStd_AsciiString) anAsciiStr; + if ( aLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) ) + aRes = QString( anAsciiStr->Get().ToCString() ); + } return aRes; } -- 2.39.2