More mutex locking for SCH_FIELDs.
Fixes: lp:1822678 * https://bugs.launchpad.net/kicad/+bug/1822678
This commit is contained in:
parent
120ab06db4
commit
5ac96c6127
|
@ -79,6 +79,10 @@ EDA_ITEM* SCH_FIELD::Clone() const
|
||||||
|
|
||||||
const wxString SCH_FIELD::GetFullyQualifiedText() const
|
const wxString SCH_FIELD::GetFullyQualifiedText() 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<std::mutex> guard( m_mutex );
|
||||||
|
|
||||||
wxString text = m_Text;
|
wxString text = m_Text;
|
||||||
|
|
||||||
/* For more than one part per package, we must add the part selection
|
/* For more than one part per package, we must add the part selection
|
||||||
|
@ -98,6 +102,36 @@ const wxString SCH_FIELD::GetFullyQualifiedText() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const wxString SCH_FIELD::GetText() 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<std::mutex> guard( m_mutex );
|
||||||
|
|
||||||
|
return m_Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString SCH_FIELD::GetShownText() 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<std::mutex> guard( m_mutex );
|
||||||
|
|
||||||
|
return m_Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_FIELD::SetText( const wxString& aText )
|
||||||
|
{
|
||||||
|
// 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 );
|
||||||
|
|
||||||
|
m_Text = aText;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_FIELD::GetPenSize() const
|
int SCH_FIELD::GetPenSize() const
|
||||||
{
|
{
|
||||||
int pensize = GetThickness();
|
int pensize = GetThickness();
|
||||||
|
|
|
@ -90,6 +90,10 @@ public:
|
||||||
|
|
||||||
void SetId( int aId ) { m_id = aId; }
|
void SetId( int aId ) { m_id = aId; }
|
||||||
|
|
||||||
|
const wxString GetText() const override;
|
||||||
|
wxString GetShownText() const override;
|
||||||
|
void SetText( const wxString& aText ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetFullyQualifiedText
|
* Function GetFullyQualifiedText
|
||||||
* returns the fully qualified field text by allowing for the part suffix to be added
|
* returns the fully qualified field text by allowing for the part suffix to be added
|
||||||
|
|
|
@ -139,8 +139,12 @@ public:
|
||||||
* returns the string associated with the text object.
|
* returns the string associated with the text object.
|
||||||
*
|
*
|
||||||
* @return a const wxString reference containing the string of the item.
|
* @return a const wxString reference containing the string of the item.
|
||||||
|
*
|
||||||
|
* WARNING: this routine MUST NOT return a reference!
|
||||||
|
* While it would be faster, it would also defeat the use of RAII mutex locks
|
||||||
|
* in subclasses to get around wxString's multi-threading bugs in UTF-8 mode.
|
||||||
*/
|
*/
|
||||||
const wxString& GetText() const { return m_Text; }
|
virtual const wxString/* & forbidden */ GetText() const { return m_Text; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string actually shown after processing of the base
|
* Returns the string actually shown after processing of the base
|
||||||
|
|
Loading…
Reference in New Issue