mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Fixes to thread safety
This commit is contained in:
@@ -64,9 +64,9 @@
|
||||
|
||||
Interface_FileReaderTool::Interface_FileReaderTool ()
|
||||
{
|
||||
themessenger = Message::DefaultMessenger();
|
||||
//themessenger = Message::DefaultMessenger();
|
||||
theerrhand = Standard_True;
|
||||
thetrace = 1;
|
||||
thetrace = 0;
|
||||
thenbrep0 = thenbreps = 0;
|
||||
}
|
||||
|
||||
@@ -334,8 +334,11 @@ void Interface_FileReaderTool::LoadModel
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
// Sendinf of message : Internal error during the header reading
|
||||
if (!TF.IsNull())
|
||||
{
|
||||
Message_Msg Msg11("XSTEP_11");
|
||||
TF->Send (Msg11, Message_Info);
|
||||
TF->Send(Msg11, Message_Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -367,9 +370,12 @@ void Interface_FileReaderTool::LoadModel
|
||||
// .. Fin Lecture ..
|
||||
if (anent.IsNull()) {
|
||||
// Sending of message : Number of ignored Null Entities
|
||||
if (!TF.IsNull())
|
||||
{
|
||||
Message_Msg Msg21("XSTEP_21");
|
||||
Msg21.Arg(amodel->NbEntities());
|
||||
TF->Send (Msg21, Message_Info);
|
||||
TF->Send(Msg21, Message_Info);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// LoadedEntity fait AddEntity MAIS PAS SetReport (en bloc a la fin)
|
||||
@@ -395,9 +401,14 @@ void Interface_FileReaderTool::LoadModel
|
||||
if (thetrace > 0)
|
||||
{
|
||||
// Sending of message : Number of ignored Null Entities
|
||||
if (!TF.IsNull())
|
||||
{
|
||||
|
||||
Message_Msg Msg21("XSTEP_21");
|
||||
Msg21.Arg(amodel->NbEntities()+1);
|
||||
TF->Send (Msg21, Message_Info);
|
||||
Msg21.Arg(amodel->NbEntities() + 1);
|
||||
|
||||
TF->Send(Msg21, Message_Info);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -409,9 +420,12 @@ void Interface_FileReaderTool::LoadModel
|
||||
|
||||
if (ierr == 2) {
|
||||
// Sending of message : reading of entity failed
|
||||
if (!TF.IsNull())
|
||||
{
|
||||
Message_Msg Msg22("XSTEP_22");
|
||||
Msg22.Arg(amodel->StringLabel(anent));
|
||||
TF->Send (Msg22, Message_Info);
|
||||
TF->Send(Msg22, Message_Info);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -421,9 +435,12 @@ void Interface_FileReaderTool::LoadModel
|
||||
// ce qui serait bien ici serait de recuperer le texte de l erreur pour ach ...
|
||||
if (thetrace > 0) {
|
||||
// Sending of message : recovered entity
|
||||
if (!TF.IsNull())
|
||||
{
|
||||
Message_Msg Msg23("XSTEP_23");
|
||||
Msg23.Arg(num);
|
||||
TF->Send (Msg23, Message_Info);
|
||||
TF->Send(Msg23, Message_Info);
|
||||
}
|
||||
}
|
||||
|
||||
// Finalement, on charge une Entite Inconnue
|
||||
@@ -444,9 +461,12 @@ void Interface_FileReaderTool::LoadModel
|
||||
else {
|
||||
if (thetrace > 0) {
|
||||
// Sending of message : reading of entity failed
|
||||
if (!TF.IsNull())
|
||||
{
|
||||
Message_Msg Msg22("XSTEP_22");
|
||||
Msg22.Arg(amodel->StringLabel(anent));
|
||||
TF->Send (Msg22, Message_Info);
|
||||
TF->Send(Msg22, Message_Info);
|
||||
}
|
||||
}
|
||||
// On garde <rep> telle quelle : pas d analyse fichier supplementaire,
|
||||
// Mais la phase preliminaire eventuelle est conservee
|
||||
@@ -460,9 +480,12 @@ void Interface_FileReaderTool::LoadModel
|
||||
if (thetrace > 0)
|
||||
{
|
||||
// Sending of message : report
|
||||
if (!TF.IsNull())
|
||||
{
|
||||
Message_Msg Msg24("XSTEP_24");
|
||||
Msg24.Arg(thenbreps);
|
||||
TF->Send (Msg24, Message_Info);
|
||||
TF->Send(Msg24, Message_Info);
|
||||
}
|
||||
}
|
||||
amodel->Reservate (-thenbreps-10);
|
||||
thenbreps = thereports->Upper();
|
||||
@@ -483,8 +506,11 @@ void Interface_FileReaderTool::LoadModel
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
// Sendinf of message : Internal error during the header reading
|
||||
if (!TF.IsNull())
|
||||
{
|
||||
Message_Msg Msg11("XSTEP_11");
|
||||
TF->Send (Msg11, Message_Info);
|
||||
TF->Send(Msg11, Message_Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -513,10 +539,13 @@ Handle(Standard_Transient) Interface_FileReaderTool::LoadedEntity
|
||||
// Trace Entite Inconnue
|
||||
if (thetrace >= 2 && theproto->IsUnknownEntity(anent)) {
|
||||
Handle(Message_Messenger) TF = Messenger();
|
||||
if (!TF.IsNull())
|
||||
{
|
||||
Message_Msg Msg22("XSTEP_22");
|
||||
// Sending of message : reading of entity failed
|
||||
Msg22.Arg(themodel->StringLabel(anent)->String());
|
||||
TF->Send (Msg22, Message_Info);
|
||||
TF->Send(Msg22, Message_Info);
|
||||
}
|
||||
}
|
||||
// .. Chargement proprement dit : Specifique de la Norme ..
|
||||
AnalyseRecord(num,anent,ach);
|
||||
@@ -545,7 +574,7 @@ Handle(Standard_Transient) Interface_FileReaderTool::LoadedEntity
|
||||
}
|
||||
thereports->SetValue(irep,rep);
|
||||
|
||||
if ( thetrace >= 2)
|
||||
if ( thetrace >= 2 && !Messenger().IsNull())
|
||||
ach->Print (Messenger(),2);
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Standard_Mutex.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -27,6 +28,8 @@
|
||||
//=======================================================================
|
||||
const Handle(Message_Messenger)& Message::DefaultMessenger ()
|
||||
{
|
||||
static Standard_Mutex aMutex;
|
||||
Standard_Mutex::Sentry aLock(aMutex);
|
||||
static Handle(Message_Messenger) aMessenger = new Message_Messenger;
|
||||
return aMessenger;
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <Message_Printer.hxx>
|
||||
#include <Message_PrinterOStream.hxx>
|
||||
#include <Standard_Mutex.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Message_Messenger,Standard_Transient)
|
||||
|
||||
@@ -87,6 +88,8 @@ Standard_Boolean Message_Messenger::RemovePrinter (const Handle(Message_Printer)
|
||||
|
||||
Standard_Integer Message_Messenger::RemovePrinters (const Handle(Standard_Type)& theType)
|
||||
{
|
||||
static Standard_Mutex aMutex;
|
||||
Standard_Mutex::Sentry aLock(aMutex);
|
||||
// remove printers from the list
|
||||
Standard_Integer nb = 0;
|
||||
for (Message_SequenceOfPrinters::Iterator aPrinterIter (myPrinters); aPrinterIter.More();)
|
||||
|
Reference in New Issue
Block a user