From 6fab7cc02512ddc47d42403d4d1ea3f88f832d14 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 5 Jun 2019 21:05:30 +0100 Subject: [PATCH] Remove a bunch of ugly mutex hacks now that we don't use wxString's UTF8 mode anymore. --- eeschema/sch_field.cpp | 38 ------------------- eeschema/sch_field.h | 6 --- include/eda_text.h | 28 +------------- ...board_items_to_polygon_shape_transform.cpp | 4 -- pcbnew/tools/pcb_editor_control.cpp | 1 - 5 files changed, 1 insertion(+), 76 deletions(-) diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index e955088940..1494339651 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -74,10 +74,6 @@ EDA_ITEM* SCH_FIELD::Clone() 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 guard( m_mutex ); - wxString text = m_Text; /* For more than one part per package, we must add the part selection @@ -97,36 +93,6 @@ 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 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 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 guard( m_mutex ); - - m_Text = aText; -} - - int SCH_FIELD::GetPenSize() const { int pensize = GetThickness(); @@ -291,10 +257,6 @@ 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 ); - return m_Text.Len() == 0; } diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index 08c4456272..e430881fca 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -55,8 +55,6 @@ 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 ); @@ -106,10 +104,6 @@ public: void SetId( int aId ) { m_id = aId; } - const wxString GetText() const override; - wxString GetShownText() const override; - void SetText( const wxString& aText ) override; - /** * Function GetFullyQualifiedText * returns the fully qualified field text by allowing for the part suffix to be added diff --git a/include/eda_text.h b/include/eda_text.h index 149a6cfa95..474452bf6b 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -22,36 +22,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file eda_text.h - * @brief Definition of base KiCad text object. - */ - #ifndef EDA_TEXT_H_ #define EDA_TEXT_H_ -#include #include // NORMALIZE_ANGLE_POS( angle ); #include // wxStringSplit #include // EDA_DRAW_MODE_T #include // EDA_RECT - -#include #include "kicad_string.h" class SHAPE_POLY_SET; -// 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; } -}; - - // part of the kicad_plugin.h family of defines. // See kicad_plugin.h for the choice of the value // When set when calling EDA_TEXT::Format, disable writing the "hide" keyword in save file @@ -139,12 +120,8 @@ public: * returns the string associated with the text object. * * @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. */ - virtual const wxString/* & forbidden */ GetText() const { return m_Text; } + virtual const wxString& GetText() const { return m_Text; } /** * Returns the string actually shown after processing of the base @@ -375,9 +352,6 @@ protected: /// Cache of unescaped text for efficient access wxString m_shown_text; - // wxString isn't thread-safe, so make use of this in multi-threaded situations - mutable UNIQUE_MUTEX m_mutex; - private: /** * Function printOneLineOfText diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index ee781f60de..fa49292c29 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -350,10 +350,6 @@ void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet( void EDA_TEXT::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 guard( m_mutex ); - if( GetText().Length() == 0 ) return; diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 82f340a1fd..2784b66214 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -24,7 +24,6 @@ */ #include #include -#include #include #include "pcb_editor_control.h" #include "pcb_actions.h"