Search found 9 matches

by jpo234
Tue Mar 31, 2020 11:55 am
Forum: Platform Related Issues
Topic: GTK2: wxListCtrl::SortItems throws an assertion when called from event handler
Replies: 3
Views: 278

Re: GTK2: wxListCtrl::SortItems throws an assertion when called from event handler

PB wrote:
Tue Mar 31, 2020 11:27 am
The common solution is to use one of the two CallAfter() variants.
Thanks! While I already found my own fix, this is good to know.
by jpo234
Tue Mar 31, 2020 11:21 am
Forum: Platform Related Issues
Topic: GTK2: wxListCtrl::SortItems throws an assertion when called from event handler
Replies: 3
Views: 278

Re: GTK2: wxListCtrl::SortItems throws an assertion when called from event handler

Small correction: The problem happens when I call wxListCtrl::SortItems from the wxEVT_COMMAND_LIST_DELETE_ITEM handler. Since deletion doesn't change the sorting, the fix is to not call wxListCtrl::SortItems on wxEVT_COMMAND_LIST_DELETE_ITEM. BUT : The assertion still bothers me. The sorting on del...
by jpo234
Tue Mar 31, 2020 11:03 am
Forum: Platform Related Issues
Topic: GTK2: wxListCtrl::SortItems throws an assertion when called from event handler
Replies: 3
Views: 278

GTK2: wxListCtrl::SortItems throws an assertion when called from event handler

Hello all, to keep the items in a wxListCtrl sorted, I'm calling wxListCtrl::SortItems in a handler for wxEVT_COMMAND_LIST_INSERT_ITEM or wxEVT_COMMAND_LIST_DELETE_ITEM. This works fine on Windows, but throws the following assertion in Linux with GTK2: ../src/generic/listctrl.cpp(4473): assert "IsEm...
by jpo234
Mon Mar 30, 2020 12:21 pm
Forum: C++ Development
Topic: wxListCtrl: ID vs. Index
Replies: 5
Views: 288

Re: wxListCtrl: ID vs. Index

PB wrote:
Mon Mar 30, 2020 11:57 am
But if you want just a numeric ID, why not use wxListCtrl::SetItemData(long, long)?
I was thinking about this very option. I think this is what I'm going to do. My lists aren't long, so a

Code: Select all

wxListCtrl::whatever(wxListCtrl::FindItem(-1, myid));
won't kill me.

Thanks
J.
by jpo234
Mon Mar 30, 2020 11:26 am
Forum: C++ Development
Topic: wxListCtrl: ID vs. Index
Replies: 5
Views: 288

Re: wxListCtrl: ID vs. Index

I think you do not have to be concerned about this. I believe it is generally not possible for the wxListItem id (= 0-based position of the id in the list control) to be different from the actual item list index. Of course, the returned index can still be different than the id when inserting an ite...
by jpo234
Mon Mar 30, 2020 8:19 am
Forum: C++ Development
Topic: wxListCtrl: ID vs. Index
Replies: 5
Views: 288

Re: wxListCtrl: ID vs. Index

I'd like to point out, that the examples on the Wiki page contradict each other on this topic. The "Minimal example to get started" does this: for (int n=0; n<item_amount; n++) { Item* curritem = getItem(n); wxListItem item; item.SetId(n); item.SetText( curritem->getName() ); m_item_list->InsertItem...
by jpo234
Thu Mar 26, 2020 6:11 pm
Forum: C++ Development
Topic: wxListCtrl: ID vs. Index
Replies: 5
Views: 288

wxListCtrl: ID vs. Index

Hello all, accessing items in a wxListCtrl happens with the help of a long value that is always named "item". Examples: wxUIntPtr wxListCtrl::GetItemData( long item) const; bool wxListCtrl::DeleteItem ( long item); Now my question: long wxListCtrl::InsertItem (wxListItem & info) is documented as Ins...
by jpo234
Thu Mar 26, 2020 5:17 pm
Forum: C++ Development
Topic: wxListCtrl::SetItemPtrData: Who owns the memory?
Replies: 2
Views: 191

Re: wxListCtrl::SetItemPtrData: Who owns the memory?

I think wxListCtrl just stores this data and never does anything with them. If the ptrdata contains a pointer to a dynamically allocated memory (it can be just integer as well), the application programmer is responsible for freeing the memory when it makes sense. If the lifetime of the objects stor...
by jpo234
Thu Mar 26, 2020 3:09 pm
Forum: C++ Development
Topic: wxListCtrl::SetItemPtrData: Who owns the memory?
Replies: 2
Views: 191

wxListCtrl::SetItemPtrData: Who owns the memory?

Hello all, if I put a pointer to an instance of something into a wxListCtrl: Who owns the memory? I assume it's the caller of wxListCtrl::SetItemPtrData since there is no deleter passed along with the pointer... If so, when is it save to delete the object pointed to by the pointer? Is there a best p...