Don't allow selection flags to leak in to the libmanager cache.

Fixes https://gitlab.com/kicad/code/kicad/issues/4021
This commit is contained in:
Jeff Young 2020-03-21 23:24:41 +00:00
parent 66382db7dd
commit d25a63cd02
3 changed files with 27 additions and 48 deletions

View File

@ -54,41 +54,32 @@ static const unsigned char dummy_png[] = {
static const BITMAP_OPAQUE dummy_xpm[1] = {{ dummy_png, sizeof( dummy_png ), "dummy_xpm" }}; static const BITMAP_OPAQUE dummy_xpm[1] = {{ dummy_png, sizeof( dummy_png ), "dummy_xpm" }};
enum textbox { EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ) :
ID_TEXTBOX_LIST = 8010 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 ) EDA_ITEM::EDA_ITEM( KICAD_T idType ) :
{ m_StructType( idType ),
initVars(); m_Status( 0 ),
m_StructType = idType; m_Parent( nullptr ),
m_Parent = parent; m_forceVisible( false ),
} m_Flags( 0 )
{ }
EDA_ITEM::EDA_ITEM( KICAD_T idType ) EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ) :
{ m_Uuid( base.m_Uuid ),
initVars(); m_StructType( base.m_StructType ),
m_StructType = idType; m_Status( base.m_Status ),
} m_Parent( base.m_Parent ),
m_forceVisible( base.m_forceVisible ),
m_Flags( base.m_Flags )
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.
}
void EDA_ITEM::SetModified() void EDA_ITEM::SetModified()

View File

@ -135,6 +135,8 @@ LIB_PART::LIB_PART( const LIB_PART& aPart, PART_LIB* aLibrary ) :
m_keyWords = aPart.m_keyWords; m_keyWords = aPart.m_keyWords;
m_docFileName = aPart.m_docFileName; m_docFileName = aPart.m_docFileName;
ClearSelected();
for( const LIB_ITEM& oldItem : aPart.m_drawings ) for( const LIB_ITEM& oldItem : aPart.m_drawings )
{ {
if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 ) if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 )
@ -143,6 +145,7 @@ LIB_PART::LIB_PART( const LIB_PART& aPart, PART_LIB* aLibrary ) :
try try
{ {
newItem = (LIB_ITEM*) oldItem.Clone(); newItem = (LIB_ITEM*) oldItem.Clone();
newItem->ClearSelected();
newItem->SetParent( this ); newItem->SetParent( this );
m_drawings.push_back( newItem ); m_drawings.push_back( newItem );
} }

View File

@ -169,37 +169,25 @@ public:
const KIID m_Uuid; const KIID m_Uuid;
private: private:
/** /**
* Run time identification, _keep private_ so it can never be changed after * Run time identification, _keep private_ so it can never be changed after
* a constructor sets it. See comment near SetType() regarding virtual * a constructor sets it. See comment near SetType() regarding virtual
* functions. * functions.
*/ */
KICAD_T m_StructType; KICAD_T m_StructType;
STATUS_FLAGS m_Status;
protected: protected:
STATUS_FLAGS m_Status;
EDA_ITEM* m_Parent; ///< Linked list: Link (parent struct) EDA_ITEM* m_Parent; ///< Linked list: Link (parent struct)
/// Set to true to override the visibility setting of the item.
bool m_forceVisible; bool m_forceVisible;
/// Flag bits for editing and other uses.
STATUS_FLAGS m_Flags; STATUS_FLAGS m_Flags;
private:
void initVars();
protected: protected:
EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ); EDA_ITEM( EDA_ITEM* parent, KICAD_T idType );
EDA_ITEM( KICAD_T idType ); EDA_ITEM( KICAD_T idType );
EDA_ITEM( const EDA_ITEM& base ); EDA_ITEM( const EDA_ITEM& base );
public: public:
virtual ~EDA_ITEM() { }; virtual ~EDA_ITEM() { };
/** /**
@ -209,10 +197,7 @@ public:
* after a constructor sets it, so there is no public "setter" method. * after a constructor sets it, so there is no public "setter" method.
* @return KICAD_T - the type of object. * @return KICAD_T - the type of object.
*/ */
inline KICAD_T Type() const inline KICAD_T Type() const { return m_StructType; }
{
return m_StructType;
}
EDA_ITEM* GetParent() const { return m_Parent; } EDA_ITEM* GetParent() const { return m_Parent; }
void SetParent( EDA_ITEM* aParent ) { m_Parent = aParent; } void SetParent( EDA_ITEM* aParent ) { m_Parent = aParent; }