Workaround for wxString's lack of thread safety.

This commit is contained in:
Jeff Young 2018-04-05 22:40:02 +01:00
parent 611d5a0dc4
commit db73daa09c
2 changed files with 17 additions and 0 deletions

View File

@ -405,6 +405,10 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
SHAPE_POLY_SET& aCornerBuffer,
int aClearanceValue ) const
{
// Oh dear. When in UTF-8 mode, wxString puts string iterators in a linked list, and
// that linked list is not thread-safe.
std::lock_guard<std::mutex> guard( m_mutex );
if( GetText().Length() == 0 )
return;

View File

@ -40,6 +40,17 @@ class EDA_DRAW_PANEL;
class MSG_PANEL_ITEM;
// A mutex which is unique to each instance it appears in (ie: a new std::mutex is allocated
// on copy or assignment).
class UNIQUE_MUTEX : public std::mutex
{
public:
UNIQUE_MUTEX() : std::mutex() {}
UNIQUE_MUTEX( const UNIQUE_MUTEX& ) : std::mutex() {}
UNIQUE_MUTEX& operator= (const UNIQUE_MUTEX& ) { return *this; }
};
class TEXTE_PCB : public BOARD_ITEM, public EDA_TEXT
{
public:
@ -142,6 +153,8 @@ public:
virtual void SwapData( BOARD_ITEM* aImage ) override;
mutable UNIQUE_MUTEX m_mutex;
#if defined(DEBUG)
virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif