wxList::Insert() bug fixed

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1998-11-26 14:08:16 +00:00
parent 225526039b
commit ff528365c8

View File

@ -49,6 +49,27 @@
// implementation // implementation
// ============================================================================= // =============================================================================
// -----------------------------------------------------------------------------
// wxListKey
// -----------------------------------------------------------------------------
bool wxListKey::operator==(wxListKeyValue value) const
{
switch ( m_keyType )
{
default:
wxFAIL_MSG("bad key type.");
// let compiler optimize the line above away in release build
// by not putting return here...
case wxKEY_STRING:
return strcmp(m_key.string, value.string) == 0;
case wxKEY_INTEGER:
return m_key.integer == value.integer;
}
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// wxNodeBase // wxNodeBase
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -206,16 +227,26 @@ wxNodeBase *wxListBase::Insert(wxNodeBase *position, void *object)
wxCHECK_MSG( m_keyType == wxKEY_NONE, (wxNodeBase *)NULL, wxCHECK_MSG( m_keyType == wxKEY_NONE, (wxNodeBase *)NULL,
"need a key for the object to insert" ); "need a key for the object to insert" );
wxNodeBase *prev = (wxNodeBase *)NULL; wxCHECK_MSG( !position || position->m_list == this, (wxNodeBase *)NULL,
if ( position ) "can't insert before a node from another list" );
prev = position->GetPrevious();
//else
// inserting in the beginning of the list
wxNodeBase *node = CreateNode(prev, position, object); // previous and next node for the node being inserted
wxNodeBase *prev, *next;
if ( position )
{
prev = position->GetPrevious();
next = position;
}
else
{
// inserting in the beginning of the list
prev = (wxNodeBase *)NULL;
next = m_nodeFirst;
}
wxNodeBase *node = CreateNode(prev, next, object);
if ( !m_nodeFirst ) if ( !m_nodeFirst )
{ {
m_nodeFirst = node;
m_nodeLast = node; m_nodeLast = node;
} }
@ -440,23 +471,6 @@ void wxListBase::Sort(const wxSortCompareFunction compfunc)
delete[] objArray; delete[] objArray;
} }
bool wxListKey::operator==(wxListKeyValue value) const
{
switch ( m_keyType )
{
default:
wxFAIL_MSG("bad key type.");
// let compiler optimize the line above away in release build
// by not putting return here...
case wxKEY_STRING:
return strcmp(m_key.string, value.string) == 0;
case wxKEY_INTEGER:
return m_key.integer == value.integer;
}
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// wxList (a.k.a. wxObjectList) // wxList (a.k.a. wxObjectList)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------