On Tue, Sep 18, 2018 at 11:15:58PM +0300, Gabriel Ivăncescu wrote:
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com
dlls/user32/listbox.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index c8bd148..a8de8d3 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -1763,18 +1763,31 @@ static LRESULT LISTBOX_SetCount( LB_DESCR *descr, INT count ) return LB_ERR; }
- /* FIXME: this is far from optimal... */ if (count > descr->nb_items) {
while (count > descr->nb_items)
if ((ret = LISTBOX_InsertString( descr, -1, 0 )) < 0)
return ret;
INT num = descr->nb_items;
if ((ret = LISTBOX_InitStorage(descr, count - num)) != LB_OKAY)
return ret;
memset(&descr->items[num], 0, (count - num) * sizeof(*descr->items));
descr->nb_items = count;
LISTBOX_UpdateScroll(descr);
LISTBOX_InvalidateItems(descr, num);
/* If listbox was empty, set focus to the first item */
if (count == 1) LISTBOX_SetCaretIndex(descr, 0, FALSE);
Shouldn't this be if (num == 0) ? That would at least match the comment.
Huw.