diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 0c4ee8352f..852925c5e2 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -312,6 +312,18 @@ bool SCH_FIELD::IsHorizJustifyFlipped() const } +bool SCH_FIELD::IsVoid() const +{ + // When in UTF-8 mode, wxString puts string iterators in a linked list, and + // that linked list is not thread-safe. + std::lock_guard guard( m_mutex ); + + size_t len = m_Text.Len(); + + return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) ); +} + + void SCH_FIELD::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) { frame->GetCanvas()->SetMouseCapture( NULL, NULL ); diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index dcccc910e6..8adf7526ff 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -59,6 +59,8 @@ class SCH_FIELD : public SCH_ITEM, public EDA_TEXT wxString m_name; + mutable UNIQUE_MUTEX m_mutex; + public: SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, const wxString& aName = wxEmptyString ); @@ -113,12 +115,7 @@ public: * Function IsVoid * returns true if the field is either empty or holds "~". */ - bool IsVoid() const - { - size_t len = m_Text.Len(); - - return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) ); - } + bool IsVoid() const; void SwapData( SCH_ITEM* aItem ) override;