Huw Davies : user32/listbox: Use helper functions for item initialization.

Alexandre Julliard julliard at winehq.org
Fri Mar 1 16:42:09 CST 2019


Module: wine
Branch: master
Commit: 0092a4bb19e808342d2761d72b5ad21e8825fa03
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=0092a4bb19e808342d2761d72b5ad21e8825fa03

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Feb 28 15:10:29 2019 +0200

user32/listbox: Use helper functions for item initialization.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/listbox.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index 75257ad..127ba35 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -166,6 +166,11 @@ static WCHAR *get_item_string( const LB_DESCR *descr, UINT index )
     return HAS_STRINGS(descr) ? descr->items[index].str : NULL;
 }
 
+static void set_item_string( const LB_DESCR *descr, UINT index, WCHAR *string )
+{
+    if (!(descr->style & LBS_NODATA)) descr->items[index].str = string;
+}
+
 static UINT get_item_height( const LB_DESCR *descr, UINT index )
 {
     return (descr->style & LBS_NODATA) ? 0 : descr->items[index].height;
@@ -189,7 +194,7 @@ static void set_item_selected_state(LB_DESCR *descr, UINT index, BOOL state)
         descr->items[index].selected = state;
 }
 
-static void insert_item_data(LB_DESCR *descr, UINT index, WCHAR *str, ULONG_PTR data)
+static void insert_item_data(LB_DESCR *descr, UINT index)
 {
     LB_ITEMDATA *item;
 
@@ -198,11 +203,6 @@ static void insert_item_data(LB_DESCR *descr, UINT index, WCHAR *str, ULONG_PTR
     item = descr->items + index;
     if (index < descr->nb_items)
         memmove(item + 1, item, (descr->nb_items - index) * sizeof(LB_ITEMDATA));
-
-    item->str      = str;
-    item->data     = HAS_STRINGS(descr) ? 0 : data;
-    item->height   = 0;
-    item->selected = FALSE;
 }
 
 static void remove_item_data(LB_DESCR *descr, UINT index)
@@ -1609,8 +1609,12 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index,
     else if ((index < 0) || (index > descr->nb_items)) return LB_ERR;
     if (!resize_storage(descr, descr->nb_items + 1)) return LB_ERR;
 
-    insert_item_data(descr, index, str, data);
+    insert_item_data(descr, index);
     descr->nb_items++;
+    set_item_string(descr, index, str);
+    set_item_data(descr, index, HAS_STRINGS(descr) ? 0 : data);
+    set_item_height(descr, index, 0);
+    set_item_selected_state(descr, index, FALSE);
 
     /* Get item height */
 




More information about the wine-cvs mailing list