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" }};
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()

View File

@ -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 );
}

View File

@ -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; }