shortcut_catcher: Fix KeyCommandMap::_DeleteHKSList()

You can't increment the list item counter as you delete because the count
decreases as you go. Instead delete the first item until there are no more
items, then delete the list.
This commit is contained in:
John Scipione 2014-06-12 18:26:52 -04:00
parent 2776568d27
commit cb3243fbbd
1 changed files with 11 additions and 9 deletions

View File

@ -1,9 +1,10 @@
/*
* Copyright 1999-2009 Haiku Inc. All rights reserved.
* Copyright 1999-2014 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Jeremy Friesner
* John Scipione, jscipione@gmail.com
*/
@ -323,16 +324,17 @@ KeyCommandMap::MessageReceived(BMessage* msg)
}
//! Deletes an HKS-filled BList and its contents.
// deletes the BList and its contents
void
KeyCommandMap::_DeleteHKSList(BList* l)
KeyCommandMap::_DeleteHKSList(BList* list)
{
if (l != NULL) {
int num = l->CountItems();
for (int i = 0; i < num; i++)
delete ((hks*) l->ItemAt(i));
delete l;
}
if (list == NULL)
return;
while (list->ItemAt(0) != NULL)
delete list->ItemAt(0);
delete list;
}