Jump to content

"Index out of range" when using RemoveItem


Vida Marcell
 Share

Recommended Posts

Is the program somehow executing the delete event when you click add?  Use a break point on bakerlist->RemoveItem(1) to find out.  If it is, then after adding one item, its trying to remove index 1 which doesn't exist yet.  Not sure why it's trying to remove it though.

 

If you're trying to remove the last element, check if the element you want to remove actually exists in the array.

int size = bakerlist->GetSize();
if (size != 0){
	bakerlist->RemoveItem(size - 1);
}

(Not sure what the right syntax is for the widget your using)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...