Make the wxDataViewItem(void*) constructor explicit.
Not having this as an implicit one made it possible to create wxDataViewItem from any pointer without realizing it, leading to hard to debug crashes later. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68621 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -81,10 +81,11 @@ extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr[];
|
|||||||
class WXDLLIMPEXP_ADV wxDataViewItem
|
class WXDLLIMPEXP_ADV wxDataViewItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxDataViewItem( void* id = NULL )
|
wxDataViewItem() : m_id(NULL) {}
|
||||||
{ m_id = id; }
|
wxDataViewItem(const wxDataViewItem &item) : m_id(item.m_id) {}
|
||||||
wxDataViewItem( const wxDataViewItem &item )
|
|
||||||
{ m_id = item.m_id; }
|
wxEXPLICIT wxDataViewItem(void* id) : m_id(id) {}
|
||||||
|
|
||||||
bool IsOk() const { return m_id != NULL; }
|
bool IsOk() const { return m_id != NULL; }
|
||||||
void* GetID() const { return m_id; }
|
void* GetID() const { return m_id; }
|
||||||
operator const void* () const { return m_id; }
|
operator const void* () const { return m_id; }
|
||||||
|
@@ -614,8 +614,9 @@ public:
|
|||||||
/**
|
/**
|
||||||
Constructor.
|
Constructor.
|
||||||
*/
|
*/
|
||||||
wxDataViewItem(void* id = NULL);
|
wxDataViewItem();
|
||||||
wxDataViewItem(const wxDataViewItem& item);
|
wxDataViewItem(const wxDataViewItem& item);
|
||||||
|
explicit wxDataViewItem(void* id);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -387,7 +387,7 @@ wxDataViewIndexListModel::wxDataViewIndexListModel( unsigned int initial_size )
|
|||||||
// build initial index
|
// build initial index
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 1; i < initial_size+1; i++)
|
for (i = 1; i < initial_size+1; i++)
|
||||||
m_hash.Add( wxUIntToPtr(i) );
|
m_hash.Add( wxDataViewItem(wxUIntToPtr(i)) );
|
||||||
m_nextFreeID = initial_size + 1;
|
m_nextFreeID = initial_size + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +403,7 @@ void wxDataViewIndexListModel::Reset( unsigned int new_size )
|
|||||||
// build initial index
|
// build initial index
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 1; i < new_size+1; i++)
|
for (i = 1; i < new_size+1; i++)
|
||||||
m_hash.Add( wxUIntToPtr(i) );
|
m_hash.Add( wxDataViewItem(wxUIntToPtr(i)) );
|
||||||
|
|
||||||
m_nextFreeID = new_size + 1;
|
m_nextFreeID = new_size + 1;
|
||||||
|
|
||||||
@@ -417,8 +417,8 @@ void wxDataViewIndexListModel::RowPrepended()
|
|||||||
unsigned int id = m_nextFreeID;
|
unsigned int id = m_nextFreeID;
|
||||||
m_nextFreeID++;
|
m_nextFreeID++;
|
||||||
|
|
||||||
m_hash.Insert( wxUIntToPtr(id), 0 );
|
|
||||||
wxDataViewItem item( wxUIntToPtr(id) );
|
wxDataViewItem item( wxUIntToPtr(id) );
|
||||||
|
m_hash.Insert( item, 0 );
|
||||||
ItemAdded( wxDataViewItem(0), item );
|
ItemAdded( wxDataViewItem(0), item );
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -430,8 +430,8 @@ void wxDataViewIndexListModel::RowInserted( unsigned int before )
|
|||||||
unsigned int id = m_nextFreeID;
|
unsigned int id = m_nextFreeID;
|
||||||
m_nextFreeID++;
|
m_nextFreeID++;
|
||||||
|
|
||||||
m_hash.Insert( wxUIntToPtr(id), before );
|
|
||||||
wxDataViewItem item( wxUIntToPtr(id) );
|
wxDataViewItem item( wxUIntToPtr(id) );
|
||||||
|
m_hash.Insert( item, before );
|
||||||
ItemAdded( wxDataViewItem(0), item );
|
ItemAdded( wxDataViewItem(0), item );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,8 +440,8 @@ void wxDataViewIndexListModel::RowAppended()
|
|||||||
unsigned int id = m_nextFreeID;
|
unsigned int id = m_nextFreeID;
|
||||||
m_nextFreeID++;
|
m_nextFreeID++;
|
||||||
|
|
||||||
m_hash.Add( wxUIntToPtr(id) );
|
|
||||||
wxDataViewItem item( wxUIntToPtr(id) );
|
wxDataViewItem item( wxUIntToPtr(id) );
|
||||||
|
m_hash.Add( item );
|
||||||
ItemAdded( wxDataViewItem(0), item );
|
ItemAdded( wxDataViewItem(0), item );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,7 +490,7 @@ unsigned int wxDataViewIndexListModel::GetRow( const wxDataViewItem &item ) cons
|
|||||||
return wxPtrToUInt(item.GetID())-1;
|
return wxPtrToUInt(item.GetID())-1;
|
||||||
|
|
||||||
// assert for not found
|
// assert for not found
|
||||||
return (unsigned int) m_hash.Index( item.GetID() );
|
return (unsigned int) m_hash.Index( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewItem wxDataViewIndexListModel::GetItem( unsigned int row ) const
|
wxDataViewItem wxDataViewIndexListModel::GetItem( unsigned int row ) const
|
||||||
@@ -2005,7 +2005,7 @@ wxDataViewItem wxDataViewTreeStore::GetNthChild( const wxDataViewItem& parent, u
|
|||||||
|
|
||||||
wxDataViewTreeStoreNodeList::compatibility_iterator node = parent_node->GetChildren().Item( pos );
|
wxDataViewTreeStoreNodeList::compatibility_iterator node = parent_node->GetChildren().Item( pos );
|
||||||
if (node)
|
if (node)
|
||||||
return node->GetData();
|
return wxDataViewItem(node->GetData());
|
||||||
|
|
||||||
return wxDataViewItem(0);
|
return wxDataViewItem(0);
|
||||||
}
|
}
|
||||||
@@ -2111,7 +2111,7 @@ void wxDataViewTreeStore::DeleteChildren( const wxDataViewItem& item )
|
|||||||
|
|
||||||
void wxDataViewTreeStore::DeleteAllItems()
|
void wxDataViewTreeStore::DeleteAllItems()
|
||||||
{
|
{
|
||||||
DeleteChildren(m_root);
|
DeleteChildren(wxDataViewItem(m_root));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -406,7 +406,7 @@ int LINKAGEMODE wxGenericTreeModelNodeCmp( wxDataViewTreeNode ** node1,
|
|||||||
|
|
||||||
int LINKAGEMODE wxGenericTreeModelItemCmp( void ** id1, void ** id2)
|
int LINKAGEMODE wxGenericTreeModelItemCmp( void ** id1, void ** id2)
|
||||||
{
|
{
|
||||||
return g_model->Compare( *id1, *id2, g_column, g_asending );
|
return g_model->Compare( wxDataViewItem(*id1), wxDataViewItem(*id2), g_column, g_asending );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2702,7 +2702,7 @@ public:
|
|||||||
if( node->GetNodes().GetCount() == 0)
|
if( node->GetNodes().GetCount() == 0)
|
||||||
{
|
{
|
||||||
int index = static_cast<int>(row) - current - 1;
|
int index = static_cast<int>(row) - current - 1;
|
||||||
ret = node->GetChildren().Item( index );
|
ret = wxDataViewItem(node->GetChildren().Item( index ));
|
||||||
return DoJob::OK;
|
return DoJob::OK;
|
||||||
}
|
}
|
||||||
return DoJob::CONT;
|
return DoJob::CONT;
|
||||||
|
@@ -300,7 +300,7 @@ private:
|
|||||||
static
|
static
|
||||||
int LINKAGEMODE wxGtkTreeModelChildCmp( void** id1, void** id2 )
|
int LINKAGEMODE wxGtkTreeModelChildCmp( void** id1, void** id2 )
|
||||||
{
|
{
|
||||||
int ret = gs_internal->GetDataViewModel()->Compare( *id1, *id2,
|
int ret = gs_internal->GetDataViewModel()->Compare( wxDataViewItem(*id1), wxDataViewItem(*id2),
|
||||||
gs_internal->GetSortColumn(), (gs_internal->GetSortOrder() == GTK_SORT_ASCENDING) );
|
gs_internal->GetSortColumn(), (gs_internal->GetSortOrder() == GTK_SORT_ASCENDING) );
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -3334,7 +3334,7 @@ int wxGtkTreeModelChildWithPosCmp( const void* data1, const void* data2, const v
|
|||||||
static
|
static
|
||||||
int LINKAGEMODE wxGtkTreeModelChildPtrCmp( void*** data1, void*** data2 )
|
int LINKAGEMODE wxGtkTreeModelChildPtrCmp( void*** data1, void*** data2 )
|
||||||
{
|
{
|
||||||
return gs_internal->GetDataViewModel()->Compare( **data1, **data2,
|
return gs_internal->GetDataViewModel()->Compare( wxDataViewItem(**data1), wxDataViewItem(**data2),
|
||||||
gs_internal->GetSortColumn(), (gs_internal->GetSortOrder() == GTK_SORT_ASCENDING) );
|
gs_internal->GetSortColumn(), (gs_internal->GetSortOrder() == GTK_SORT_ASCENDING) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user