wxTreeListItemComparator with 64bit integers

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
kurta999
Earned a small fee
Earned a small fee
Posts: 21
Joined: Sun Dec 08, 2019 8:47 pm

wxTreeListItemComparator with 64bit integers

Post by kurta999 »

Hi,

Is there a better way to use wxTreeListItemComparator with 64bit integers than modifying the types inside wxWidgets lib and rebuild it?

Thanks.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxTreeListItemComparator with 64bit integers

Post by doublemax »

Can't you just use a 64bit build? Or do you really need 64bit item-ids in a 32bit build?
Use the source, Luke!
kurta999
Earned a small fee
Earned a small fee
Posts: 21
Joined: Sun Dec 08, 2019 8:47 pm

Re: wxTreeListItemComparator with 64bit integers

Post by kurta999 »

I'm using 64bit build, but I would need to use 64bit integers in comparator which is only int, that's only 32bit.

virtual int Compare(wxTreeListCtrl* treelist, unsigned column, wxTreeListItem first, wxTreeListItem second) = 0;
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxTreeListItemComparator with 64bit integers

Post by doublemax »

kurta999 wrote: Thu Aug 18, 2022 4:06 pm virtual int Compare(wxTreeListCtrl* treelist, unsigned column, wxTreeListItem first, wxTreeListItem second) = 0;
That int is just the return value which can only be -1, 0,- 1. wxTreeListItem is a void* and therefore 64bit in a 64bit build.
Use the source, Luke!
kurta999
Earned a small fee
Earned a small fee
Posts: 21
Joined: Sun Dec 08, 2019 8:47 pm

Re: wxTreeListItemComparator with 64bit integers

Post by kurta999 »

Thank you!

Looks like it works, I copied the comprator from one wxWdigets sample which I don't remember anymore. The return value of comparator there wasn't limited to -1,0,1 - it was just: negative number, 0, positive number - in this case int64_t caused overflow to int return value. I limited the output to -1,0,1 and it works.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxTreeListItemComparator with 64bit integers

Post by ONEEYEMAN »

Hi,
It would be interesting to try and build that sample and see if it (still) gives an assert.

Thank you
kurta999
Earned a small fee
Earned a small fee
Posts: 21
Joined: Sun Dec 08, 2019 8:47 pm

Re: wxTreeListItemComparator with 64bit integers

Post by kurta999 »

Look like yes, I found the sample - its in samples/treelist (3.2.0)

https://ibb.co/V2mPxR1
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxTreeListItemComparator with 64bit integers

Post by ONEEYEMAN »

Hi,
Can you try that?

Thank you.
kurta999
Earned a small fee
Earned a small fee
Posts: 21
Joined: Sun Dec 08, 2019 8:47 pm

Re: wxTreeListItemComparator with 64bit integers

Post by kurta999 »

I've tried it and it works. But I think based on @doublemax's reply, this should be reduced to 0, -1, 1 - in the sample. I posted a screenshot about this in former post, it's from VS debugger.
Post Reply