From d25a63cd02bc5e1e5766d6a8d0ac4c3d376e5a00 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 21 Mar 2020 23:24:41 +0000 Subject: [PATCH] Don't allow selection flags to leak in to the libmanager cache. Fixes https://gitlab.com/kicad/code/kicad/issues/4021 --- common/base_struct.cpp | 53 +++++++++++++++---------------------- eeschema/class_libentry.cpp | 3 +++ include/base_struct.h | 19 ++----------- 3 files changed, 27 insertions(+), 48 deletions(-) diff --git a/common/base_struct.cpp b/common/base_struct.cpp index 1a1ac60b7e..30cca89120 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -54,41 +54,32 @@ static const unsigned char dummy_png[] = { static const BITMAP_OPAQUE dummy_xpm[1] = {{ dummy_png, sizeof( dummy_png ), "dummy_xpm" }}; -enum textbox { - ID_TEXTBOX_LIST = 8010 -}; +EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ) : + m_StructType( idType ), + m_Status( 0 ), + m_Parent( parent ), + m_forceVisible( false ), + m_Flags( 0 ) +{ } -EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ) -{ - initVars(); - m_StructType = idType; - m_Parent = parent; -} +EDA_ITEM::EDA_ITEM( KICAD_T idType ) : + m_StructType( idType ), + m_Status( 0 ), + m_Parent( nullptr ), + m_forceVisible( false ), + m_Flags( 0 ) +{ } -EDA_ITEM::EDA_ITEM( KICAD_T idType ) -{ - initVars(); - m_StructType = idType; -} - - -EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ) -{ - initVars(); - *this = base; -} - - -void EDA_ITEM::initVars() -{ - m_StructType = TYPE_NOT_INIT; - m_Parent = NULL; // Linked list: Link (parent struct) - m_Flags = 0; // flags for editions and other - m_Status = 0; - m_forceVisible = false; // true to override the visibility setting of the item. -} +EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ) : + m_Uuid( base.m_Uuid ), + m_StructType( base.m_StructType ), + m_Status( base.m_Status ), + m_Parent( base.m_Parent ), + m_forceVisible( base.m_forceVisible ), + m_Flags( base.m_Flags ) +{ } void EDA_ITEM::SetModified() diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 34f9a95fd9..30b8d0f040 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -135,6 +135,8 @@ LIB_PART::LIB_PART( const LIB_PART& aPart, PART_LIB* aLibrary ) : m_keyWords = aPart.m_keyWords; m_docFileName = aPart.m_docFileName; + ClearSelected(); + for( const LIB_ITEM& oldItem : aPart.m_drawings ) { if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 ) @@ -143,6 +145,7 @@ LIB_PART::LIB_PART( const LIB_PART& aPart, PART_LIB* aLibrary ) : try { newItem = (LIB_ITEM*) oldItem.Clone(); + newItem->ClearSelected(); newItem->SetParent( this ); m_drawings.push_back( newItem ); } diff --git a/include/base_struct.h b/include/base_struct.h index 0c082d4c78..297f8e82b4 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -169,37 +169,25 @@ public: const KIID m_Uuid; private: - /** * Run time identification, _keep private_ so it can never be changed after * a constructor sets it. See comment near SetType() regarding virtual * functions. */ KICAD_T m_StructType; - STATUS_FLAGS m_Status; protected: - + STATUS_FLAGS m_Status; EDA_ITEM* m_Parent; ///< Linked list: Link (parent struct) - - /// Set to true to override the visibility setting of the item. bool m_forceVisible; - - /// Flag bits for editing and other uses. STATUS_FLAGS m_Flags; -private: - - void initVars(); - protected: - EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ); EDA_ITEM( KICAD_T idType ); EDA_ITEM( const EDA_ITEM& base ); public: - virtual ~EDA_ITEM() { }; /** @@ -209,10 +197,7 @@ public: * after a constructor sets it, so there is no public "setter" method. * @return KICAD_T - the type of object. */ - inline KICAD_T Type() const - { - return m_StructType; - } + inline KICAD_T Type() const { return m_StructType; } EDA_ITEM* GetParent() const { return m_Parent; } void SetParent( EDA_ITEM* aParent ) { m_Parent = aParent; }