Fix crash when renaming a component in symbol library editor
COMPONENT_TREE::STATE used wxDataViewItem to store the selection, but it will point to a deleted object if the selection was removed. Switched to storing the selection using LIB_ID as it is much safer to use.
This commit is contained in:
parent
f19aed9d5c
commit
aedf24d944
|
@ -195,7 +195,7 @@ COMPONENT_TREE::STATE COMPONENT_TREE::getState() const
|
||||||
state.expanded.push_back( item );
|
state.expanded.push_back( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
state.selection = m_tree_ctrl->GetSelection();
|
state.selection = GetSelectedLibId();
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -208,11 +208,8 @@ void COMPONENT_TREE::setState( const STATE& aState )
|
||||||
for( const auto& item : aState.expanded )
|
for( const auto& item : aState.expanded )
|
||||||
m_tree_ctrl->Expand( item );
|
m_tree_ctrl->Expand( item );
|
||||||
|
|
||||||
if( aState.selection.IsOk() )
|
if( aState.selection.IsValid() )
|
||||||
{
|
SelectLibId( aState.selection );
|
||||||
m_tree_ctrl->ExpandAncestors( aState.selection );
|
|
||||||
m_tree_ctrl->SetCurrentItem( aState.selection );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ protected:
|
||||||
std::vector<wxDataViewItem> expanded;
|
std::vector<wxDataViewItem> expanded;
|
||||||
|
|
||||||
///> Current selection, might be not valid if nothing was selected
|
///> Current selection, might be not valid if nothing was selected
|
||||||
wxDataViewItem selection;
|
LIB_ID selection;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue