]> OCCT Git - occt-copy.git/commitdiff
more modifications to avoid exceptions
authoraka <aka@opencascade.com>
Mon, 28 Aug 2017 10:23:50 +0000 (13:23 +0300)
committeraka <aka@opencascade.com>
Mon, 28 Aug 2017 10:23:50 +0000 (13:23 +0300)
src/Interface/Interface_CheckTool.cxx
src/Interface/Interface_CheckTool.hxx
src/Message/Message_Msg.cxx
src/Message/Message_MsgFile.cxx
src/STEPControl/STEPControl_Controller.cxx

index cdf279620eefe49e498adf3005c8fe863a52013a..5298d693781b827a5082cd95d6a0edf6a3664d09 100644 (file)
 #endif
 #include <stdio.h>
 
-//static int errh = 1;
 
-
-static void raisecheck (Standard_Failure& theException,Handle(Interface_Check)& ach)
+void Interface_CheckTool::raisecheck (Standard_Failure& theException,Handle(Interface_Check)& ach)
 {
   char mess[100];
   sprintf (mess,"** Exception Raised during Check : %s **",
@@ -75,6 +73,7 @@ Interface_CheckTool::Interface_CheckTool(const Handle(Interface_InterfaceModel)&
        theshare (model,protocol)
 {
   thestat = 0;
+  errh = 1;
 }
 
 
@@ -88,6 +87,7 @@ Interface_CheckTool::Interface_CheckTool(const Handle(Interface_InterfaceModel)&
 {
   thestat = 0;
   thegtool->Reservate(model->NbEntities());
+  errh = 1;
 }
 
 
@@ -99,6 +99,7 @@ Interface_CheckTool::Interface_CheckTool(const Handle(Interface_InterfaceModel)&
 Interface_CheckTool::Interface_CheckTool(const Interface_Graph& graph)
      : thegtool(graph.Model()->GTool()) , theshare (graph)
 {
+  errh = 1;
 }
 
 
@@ -110,6 +111,7 @@ Interface_CheckTool::Interface_CheckTool(const Interface_Graph& graph)
 Interface_CheckTool::Interface_CheckTool(const Handle(Interface_HGraph)& hgraph)
      : thegtool(hgraph->Graph().Model()->GTool()) , theshare (hgraph)
 {
+  errh = 1;
 }
 
 
index 663f628f08c78725ce2547846a83f91900507be2..101f8c5f013fa7968471db77fe165fb6365aa263 100644 (file)
@@ -131,10 +131,12 @@ protected:
 private:
 
 
+  Standard_EXPORT void raisecheck(Standard_Failure& theException, Handle(Interface_Check)& ach);
 
   Handle(Interface_GTool) thegtool;
   Interface_ShareTool theshare;
   Standard_Integer thestat;
+  Standard_Integer errh;
 
 
 };
index bbb6f3885f60833b5dd28f0f2086244fc56b083d..9a821d642212896ff52f041e41e0a048fea0b146 100644 (file)
@@ -17,6 +17,7 @@
 #include <Message_MsgFile.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <stdio.h>
+#include <Standard_Mutex.hxx>
 
 typedef enum
 {
@@ -26,6 +27,9 @@ typedef enum
   Msg_IndefiniteType
 } FormatType;
 
+// mutex used to prevent concurrent access to message registry
+static Standard_Mutex theMutex;
+
 //=======================================================================
 //function : Message_Msg()
 //purpose  : Constructor
@@ -42,6 +46,7 @@ Message_Msg::Message_Msg ()
 
 Message_Msg::Message_Msg (const Message_Msg& theMsg)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   myMessageBody = theMsg.myMessageBody;
   myOriginal = theMsg.myOriginal;
   for ( Standard_Integer i = 1, n = theMsg.mySeqOfFormats.Length(); i <=n; i++ )
@@ -55,6 +60,7 @@ Message_Msg::Message_Msg (const Message_Msg& theMsg)
 
 Message_Msg::Message_Msg (const Standard_CString theMsgCode)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   TCollection_AsciiString aKey((char*)theMsgCode);
   Set ( Message_MsgFile::Msg(aKey) );
 }
@@ -66,6 +72,7 @@ Message_Msg::Message_Msg (const Standard_CString theMsgCode)
 
 Message_Msg::Message_Msg (const TCollection_ExtendedString& theMsgCode)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   Set ( Message_MsgFile::Msg(theMsgCode) );
 }
 
@@ -76,6 +83,7 @@ Message_Msg::Message_Msg (const TCollection_ExtendedString& theMsgCode)
 
 void Message_Msg::Set (const Standard_CString theMsg)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   TCollection_AsciiString aMsg((char*)theMsg);
   Set ( aMsg );
 }
@@ -87,6 +95,7 @@ void Message_Msg::Set (const Standard_CString theMsg)
 
 void Message_Msg::Set (const TCollection_ExtendedString& theMsg)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   myMessageBody = theMsg;
 
   const Standard_ExtString anExtString = myMessageBody.ToExtString();
@@ -157,6 +166,7 @@ void Message_Msg::Set (const TCollection_ExtendedString& theMsg)
 
 Message_Msg& Message_Msg::Arg (const Standard_CString theString)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   // get location and format
   TCollection_AsciiString aFormat;
   Standard_Integer aFirst = getFormat ( Msg_StringType, aFormat );
@@ -184,6 +194,7 @@ Message_Msg& Message_Msg::Arg (const Standard_CString theString)
 
 Message_Msg& Message_Msg::Arg (const TCollection_ExtendedString& theString)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   // get location and format
   TCollection_AsciiString aFormat;
   Standard_Integer aFirst = getFormat ( Msg_StringType, aFormat );
@@ -203,6 +214,7 @@ Message_Msg& Message_Msg::Arg (const TCollection_ExtendedString& theString)
 
 Message_Msg& Message_Msg::Arg (const Standard_Integer theValue)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   // get location and format
   TCollection_AsciiString aFormat;
   Standard_Integer aFirst = getFormat ( Msg_IntegerType, aFormat );
@@ -227,6 +239,7 @@ Message_Msg& Message_Msg::Arg (const Standard_Integer theValue)
 
 Message_Msg& Message_Msg::Arg (const Standard_Real theValue)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   // get location and format
   TCollection_AsciiString aFormat;
   Standard_Integer aFirst = getFormat ( Msg_RealType, aFormat );
@@ -251,6 +264,7 @@ Message_Msg& Message_Msg::Arg (const Standard_Real theValue)
 
 const TCollection_ExtendedString& Message_Msg::Get ()
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   // remove all non-initialised format specifications
   Standard_Integer i, anIncrement = 0;
   static const TCollection_ExtendedString anUnknown ("UNKNOWN");
@@ -279,6 +293,7 @@ const TCollection_ExtendedString& Message_Msg::Get ()
 Standard_Integer Message_Msg::getFormat (const Standard_Integer theType,
                                          TCollection_AsciiString &theFormat)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   for (Standard_Integer i = 1; i <= mySeqOfFormats.Length(); i += 3)
     if (mySeqOfFormats(i) == theType)
     {
@@ -307,6 +322,7 @@ void Message_Msg::replaceText (const Standard_Integer theFirst,
                                const Standard_Integer theNb,
                                const TCollection_ExtendedString &theStr)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   myMessageBody.Remove ( theFirst, theNb );
   myMessageBody.Insert ( theFirst, theStr );
   
index 31ff7f28d20bc996ff4c77d41c9fb0f86109bb3f..f753deeba580613e4923ae04686862b7f40875f5 100644 (file)
@@ -213,6 +213,7 @@ static Standard_Integer GetFileSize (FILE *theFile)
 
 Standard_Boolean Message_MsgFile::LoadFile (const Standard_CString theFileName)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   if (theFileName == NULL || * theFileName == '\0') return Standard_False;
 
   //    Open the file
@@ -321,6 +322,7 @@ Standard_Boolean Message_MsgFile::LoadFromEnv (const Standard_CString theEnvName
 Standard_Boolean Message_MsgFile::LoadFromString (const Standard_CString theContent,
                                                   const Standard_Integer theLength)
 {
+  Standard_Mutex::Sentry aSentry(theMutex);
   Standard_Integer aStringSize = theLength >= 0 ? theLength : (Standard_Integer )strlen (theContent);
   NCollection_Buffer aBuffer (NCollection_BaseAllocator::CommonBaseAllocator());
   if (aStringSize <= 0 || !aBuffer.Allocate (aStringSize + 2))
@@ -345,10 +347,7 @@ Standard_Boolean Message_MsgFile::AddMsg (const TCollection_AsciiString& theKeyw
                                          const TCollection_ExtendedString&  theMessage)
 {
   Standard_Mutex::Sentry aSentry(theMutex);
-  Message_DataMapOfExtendedString& aDataMap = ::msgsDataMap();
-
-  aDataMap.Bind (theKeyword, theMessage);
+  Message_DataMapOfExtendedString& aDataMap = ::msgsDataMap();  aDataMap.Bind (theKeyword, theMessage);
   return Standard_True;
 }
 
@@ -385,7 +384,6 @@ const TCollection_ExtendedString &Message_MsgFile::Msg (const TCollection_AsciiS
   Standard_Mutex::Sentry aSentry(theMutex);
   // find message in the map
   Message_DataMapOfExtendedString& aDataMap = ::msgsDataMap();
 
   // if message is not found, generate error message and add it to the map to minimize overhead
   // on consequent calls with the same key
index ab60b0e27278c01459503be7510d39ddb30fd7fe..7f11ee7235612407ac2ff3d6bf06acbef35847ca 100644 (file)
@@ -70,6 +70,12 @@ STEPControl_Controller::STEPControl_Controller()
     Standard_Mutex::Sentry aLock(aPars);
     RWHeaderSection::Init();
     RWStepAP214::Init(Handle(StepAP214_Protocol)::DownCast(myAdaptorProtocol));
+
+    // initialization of Standard Shape Healing
+    ShapeExtend::Init();
+
+    // init Standard Shape Processing operators
+    ShapeProcess_OperLibrary::Init();
   }
 
   Handle(STEPControl_ActorWrite) ActWrite = new STEPControl_ActorWrite;
@@ -163,12 +169,6 @@ STEPControl_Controller::STEPControl_Controller()
   Handle(IFSelect_EditForm) edsdrf = new IFSelect_EditForm (edsdr,Standard_False,Standard_True,"STEP Product Data (SDR)");
   AddSessionItem (edsdr,"step-SDR-edit");
   AddSessionItem (edsdrf,"step-SDR-data");
-
-  // initialization of Standard Shape Healing
-  ShapeExtend::Init();
-
-  // init Standard Shape Processing operators
-  ShapeProcess_OperLibrary::Init();
 }
 
 Handle(Interface_InterfaceModel)  STEPControl_Controller::NewModel () const
@@ -252,7 +252,12 @@ void STEPControl_Controller::Customise(Handle(XSControl_WorkSession)& WS)
     //pdn S4133 18.02.99
     WS->AddNamedItem ("xst-derived",new IFSelect_SignAncestor());
     Handle(STEPSelections_SelectDerived) stdvar = new STEPSelections_SelectDerived();
-    stdvar->SetProtocol(myAdaptorProtocol);
+
+    static Standard_Mutex aPars;
+    {
+      Standard_Mutex::Sentry aLock(aPars);
+      stdvar->SetProtocol(myAdaptorProtocol);
+    }
     WS->AddNamedItem ("step-derived",stdvar);
 
     //Creates a Selection for ShapeDefinitionRepresentation