From: mzn Date: Wed, 10 Sep 2008 13:58:46 +0000 (+0000) Subject: Fix for bug Bug IPAL20288 (4x: CRASH after trying to build a sketch). X-Git-Tag: V4_1_4a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1fbfe5fb2fd4d5668796513ee08e488d5b6314a1;p=modules%2Fgeom.git Fix for bug Bug IPAL20288 (4x: CRASH after trying to build a sketch). --- diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index d6628ca43..6585c9f7e 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -634,14 +634,13 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation * MakeSketcher */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher - (const TCollection_AsciiString& theCommand, - list theWorkingPlane) +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand, + list theWorkingPlane) { SetErrorCode(KO); - if (theCommand.IsEmpty()) return NULL; - + if (!theCommand || strcmp(theCommand, "") == 0) return NULL; + //Add a new Sketcher object Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER); @@ -654,8 +653,9 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL; GEOMImpl_ISketcher aCI (aFunction); - - aCI.SetCommand(theCommand); + + TCollection_AsciiString aCommand((char*) theCommand); + aCI.SetCommand(aCommand); int ind = 1; list::iterator it = theWorkingPlane.begin(); @@ -680,7 +680,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher //Make a Python command GEOM::TPythonDump pd (aFunction); - pd << aSketcher << " = geompy.MakeSketcher(\"" << theCommand.ToCString() << "\", ["; + pd << aSketcher << " = geompy.MakeSketcher(\"" << aCommand.ToCString() << "\", ["; it = theWorkingPlane.begin(); pd << (*it++); @@ -698,13 +698,12 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher * MakeSketcherOnPlane */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane - (const TCollection_AsciiString& theCommand, - Handle(GEOM_Object) theWorkingPlane) +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane (const char* theCommand, + Handle(GEOM_Object) theWorkingPlane) { SetErrorCode(KO); - if (theCommand.IsEmpty()) return NULL; + if (!theCommand || strcmp(theCommand, "") == 0) return NULL; //Add a new Sketcher object Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER); @@ -718,7 +717,9 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL; GEOMImpl_ISketcher aCI (aFunction); - aCI.SetCommand(theCommand); + + TCollection_AsciiString aCommand((char*) theCommand); + aCI.SetCommand(aCommand); Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction(); if (aRefPlane.IsNull()) return NULL; @@ -742,7 +743,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane //Make a Python command GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\"" - << theCommand.ToCString() << "\", " << theWorkingPlane << " )"; + << aCommand.ToCString() << "\", " << theWorkingPlane << " )"; SetErrorCode(OK); return aSketcher; diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx index 34bb01148..ed6605d0d 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx @@ -63,9 +63,9 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeSplineBezier (list thePoints); Standard_EXPORT Handle(GEOM_Object) MakeSplineInterpolation (list thePoints); - Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const TCollection_AsciiString& theCommand, + Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand, list theWorkingPlane); - Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const TCollection_AsciiString& theCommand, + Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const char* theCommand, Handle(GEOM_Object) theWorkingPlane); }; diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.cc b/src/GEOM_I/GEOM_ICurvesOperations_i.cc index 3a15afb1b..7762d6192 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.cc +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.cc @@ -386,7 +386,7 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher // Make Sketcher Handle(GEOM_Object) anObject = - GetOperations()->MakeSketcher((char*)theCommand, aWorkingPlane); + GetOperations()->MakeSketcher(theCommand, aWorkingPlane); if (!GetOperations()->IsDone() || anObject.IsNull()) return GEOM::GEOM_Object::_nil(); @@ -410,7 +410,7 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane // Make Sketcher Handle(GEOM_Object) anObject = - GetOperations()->MakeSketcherOnPlane((char*)theCommand, aWorkingPlane); + GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane); if (!GetOperations()->IsDone() || anObject.IsNull()) return GEOM::GEOM_Object::_nil();