From 48b498d4e11fea0930d2db52adba30d129c9dfea Mon Sep 17 00:00:00 2001 From: msv Date: Mon, 25 Jun 2018 10:20:10 +0300 Subject: [PATCH] Temporary fix for 0029872: Express Mesh - instrument the algorithm with progress indicator Make ProgressSentry thread safe. It will update indicator only when it is executed in the thread where it was created. --- src/Message/Message_ProgressSentry.cxx | 6 ++++-- src/Message/Message_ProgressSentry.hxx | 3 +++ src/Message/Message_ProgressSentry.lxx | 13 ++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Message/Message_ProgressSentry.cxx b/src/Message/Message_ProgressSentry.cxx index 2648816f5b..6110140468 100644 --- a/src/Message/Message_ProgressSentry.cxx +++ b/src/Message/Message_ProgressSentry.cxx @@ -27,7 +27,8 @@ Message_ProgressSentry::Message_ProgressSentry (const Handle(Message_ProgressInd const Standard_Real step, const Standard_Boolean isInf, const Standard_Real newScopeSpan) : - myProgress(progress), myActive(!progress.IsNull()) + myProgress(progress), myActive(!progress.IsNull()), + myThreadId(OSD_Thread::Current()) { if ( ! myActive ) return; progress->SetName ( name ); @@ -47,7 +48,8 @@ Message_ProgressSentry::Message_ProgressSentry (const Handle(Message_ProgressInd const Standard_Real step, const Standard_Boolean isInf, const Standard_Real newScopeSpan) : - myProgress(progress), myActive(!progress.IsNull()) + myProgress(progress), myActive(!progress.IsNull()), + myThreadId(OSD_Thread::Current()) { if ( ! myActive ) return; progress->SetName ( name ); diff --git a/src/Message/Message_ProgressSentry.hxx b/src/Message/Message_ProgressSentry.hxx index 0e7a094a5d..1d34cf43d8 100644 --- a/src/Message/Message_ProgressSentry.hxx +++ b/src/Message/Message_ProgressSentry.hxx @@ -23,6 +23,8 @@ #include #include #include +#include +#include class Message_ProgressIndicator; class TCollection_HAsciiString; @@ -109,6 +111,7 @@ private: Handle(Message_ProgressIndicator) myProgress; Standard_Boolean myActive; + Standard_ThreadId myThreadId; }; diff --git a/src/Message/Message_ProgressSentry.lxx b/src/Message/Message_ProgressSentry.lxx index e083a8ce46..03da604a93 100644 --- a/src/Message/Message_ProgressSentry.lxx +++ b/src/Message/Message_ProgressSentry.lxx @@ -20,7 +20,7 @@ inline void Message_ProgressSentry::Relieve () { - if ( ! myActive ) return; + if (!myActive || myThreadId != OSD_Thread::Current()) return; myProgress->EndScope(); myActive = 0; } @@ -32,7 +32,8 @@ inline void Message_ProgressSentry::Relieve () inline void Message_ProgressSentry::Next (const Standard_CString name) const { - if ( myActive ) myProgress->NextScope(name); + if (myActive && myThreadId == OSD_Thread::Current()) + myProgress->NextScope(name); } //======================================================================= @@ -43,7 +44,8 @@ inline void Message_ProgressSentry::Next (const Standard_CString name) const inline void Message_ProgressSentry::Next (const Standard_Real span, const Standard_CString name) const { - if ( myActive ) myProgress->NextScope(span, name); + if (myActive && myThreadId == OSD_Thread::Current()) + myProgress->NextScope(span, name); } //======================================================================= @@ -54,7 +56,7 @@ inline void Message_ProgressSentry::Next (const Standard_Real span, inline void Message_ProgressSentry::Next (const Standard_Real span, const Handle(TCollection_HAsciiString)& name) const { - if ( myActive ) { + if (myActive && myThreadId == OSD_Thread::Current()) { myProgress->EndScope(); myProgress->NewScope(span, name); } @@ -77,5 +79,6 @@ inline Standard_Boolean Message_ProgressSentry::More () const inline void Message_ProgressSentry::Show () const { - if ( ! myProgress.IsNull() ) myProgress->Show(); + if (!myProgress.IsNull() && myThreadId == OSD_Thread::Current()) + myProgress->Show(); } -- 2.39.5