mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-10-06 07:00:16 +08:00
Make wxListItemData movable and not copyable
This class contains (sometimes) owned pointers and so can't be copied but it can be moved, so make it moveable. No real changes, this is done in preparation for storing objects of this type in a std::vector.
This commit is contained in:
@@ -50,6 +50,10 @@ class wxListItemData
|
||||
{
|
||||
public:
|
||||
wxListItemData(wxListMainWindow *owner);
|
||||
wxListItemData(const wxListItemData&) = delete;
|
||||
wxListItemData(wxListItemData&&);
|
||||
wxListItemData& operator=(const wxListItemData&) = delete;
|
||||
wxListItemData& operator=(wxListItemData&&);
|
||||
~wxListItemData();
|
||||
|
||||
void SetItem( const wxListItem &info );
|
||||
|
||||
@@ -107,6 +107,28 @@ WX_DEFINE_LIST(wxListHeaderDataList)
|
||||
// wxListItemData
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxListItemData::wxListItemData(wxListItemData&& other)
|
||||
{
|
||||
m_owner = other.m_owner;
|
||||
|
||||
// Take ownership of the pointers from the other object and reset them.
|
||||
std::swap(m_attr, other.m_attr);
|
||||
std::swap(m_rect, other.m_rect);
|
||||
}
|
||||
|
||||
wxListItemData& wxListItemData::operator=(wxListItemData&& other)
|
||||
{
|
||||
m_image = other.m_image;
|
||||
m_data = other.m_data;
|
||||
m_owner = other.m_owner;
|
||||
|
||||
// Swap them to let our pointers be deleted by the other object if necessary.
|
||||
std::swap(m_attr, other.m_attr);
|
||||
std::swap(m_rect, other.m_rect);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxListItemData::~wxListItemData()
|
||||
{
|
||||
// in the virtual list control the attributes are managed by the main
|
||||
|
||||
Reference in New Issue
Block a user