libui icon indicating copy to clipboard operation
libui copied to clipboard

Fix #416, uiTableModelRowInserted on windows adds 2 rows instead of 1.

Open pftbest opened this issue 5 years ago • 2 comments

When LVM_INSERTITEM is called after we updated LVM_SETITEMCOUNT, the actual count will be increased by one causing one extra item to appear in the table and loading data from the model. This extra item is invisible at first because it doesn't get painted but you can click on it to confirm that it is actually there.

To fix the problem we need to call INSERTITEM first and then update the ITEMCOUNT.

Fixes #416 Fixes andlabs/ui#369

cc @bcampbell r? @andlabs

pftbest avatar Feb 05 '20 19:02 pftbest

Patch looks good to me.

The MS docs don't mention anything about setting an item count on insertion. Looking (again) at the WINE sources however tells me the list view increases its internal counter on LVM_INSERTITEM with LVS_OWNERDATA (which libUI uses). Debug printing the item count before and after insertion confirms this.

My only question would be: why not remove the call to LVM_SETITEMCOUNT entirely? It is clearly redundant.

szanni avatar Sep 20 '20 22:09 szanni

Yeah, I tried looking up why I did this, and couldn't find anything. "Update selection state" is a very vague comment in hindsight... I guess you can try removing the call and seeing what happens.

andlabs avatar Sep 27 '20 13:09 andlabs