[PATCH 1/2] comctl32/listbox: Fix order of items passed in WM_COMPAREITEM data.
From: Dmitry Timoshkov <dmitry(a)baikal.ru> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42602 Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/comctl32/listbox.c | 12 ++++++------ dlls/comctl32/tests/listbox.c | 4 ---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c index 94712fd1c8..a1fdf83eda 100644 --- a/dlls/comctl32/listbox.c +++ b/dlls/comctl32/listbox.c @@ -798,7 +798,7 @@ static INT LISTBOX_FindStringPos( LB_DESCR *descr, LPCWSTR str, BOOL exact ) { index = (min + max) / 2; if (HAS_STRINGS(descr)) - res = LISTBOX_lstrcmpiW( descr->locale, str, descr->items[index].str); + res = LISTBOX_lstrcmpiW( descr->locale, descr->items[index].str, str ); else { COMPAREITEMSTRUCT cis; @@ -809,15 +809,15 @@ static INT LISTBOX_FindStringPos( LB_DESCR *descr, LPCWSTR str, BOOL exact ) cis.hwndItem = descr->self; /* note that some application (MetaStock) expects the second item * to be in the listbox */ - cis.itemID1 = -1; - cis.itemData1 = (ULONG_PTR)str; - cis.itemID2 = index; - cis.itemData2 = descr->items[index].data; + cis.itemID1 = index; + cis.itemData1 = descr->items[index].data; + cis.itemID2 = -1; + cis.itemData2 = (ULONG_PTR)str; cis.dwLocaleId = descr->locale; res = SendMessageW( descr->owner, WM_COMPAREITEM, id, (LPARAM)&cis ); } if (!res) return index; - if (res < 0) max = index; + if (res > 0) max = index; else min = index + 1; } return exact ? -1 : max; diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c index 790c2c4357..69d3381cc9 100644 --- a/dlls/comctl32/tests/listbox.c +++ b/dlls/comctl32/tests/listbox.c @@ -326,9 +326,7 @@ static LRESULT WINAPI main_window_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARA ok(wParam == cis->CtlID, "expected %#x, got %#lx\n", cis->CtlID, wParam); ok(cis->hwndItem == ctrl, "expected %p, got %p\n", ctrl, cis->hwndItem); -todo_wine ok((int)cis->itemID1 >= 0, "expected >= 0, got %d\n", cis->itemID1); -todo_wine ok((int)cis->itemID2 == -1, "expected -1, got %d\n", cis->itemID2); if (cis->CtlType == ODT_LISTBOX) @@ -2030,10 +2028,8 @@ static void test_WM_MEASUREITEM(void) ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0"); ok(ret == 0, "expected 0, got %ld\n", ret); ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1"); -todo_wine ok(ret == 1, "expected 1, got %ld\n", ret); ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2"); -todo_wine ok(ret == 2, "expected 2, got %ld\n", ret); ok_sequence(sequences, PARENT_SEQ_INDEX, lb_addstring_sort_parent_seq, "LB_ADDSTRING (LBS_SORT)", TRUE); -- 2.18.0
From: Dmitry Timoshkov <dmitry(a)baikal.ru> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42602 Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/comctl32/listbox.c | 11 ++++++----- dlls/comctl32/tests/listbox.c | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c index a1fdf83eda..e033975f41 100644 --- a/dlls/comctl32/listbox.c +++ b/dlls/comctl32/listbox.c @@ -791,10 +791,11 @@ static INT LISTBOX_FindStringPos( LB_DESCR *descr, LPCWSTR str, BOOL exact ) { INT index, min, max, res; - if (!(descr->style & LBS_SORT)) return -1; /* Add it at the end */ + if (!descr->nb_items || !(descr->style & LBS_SORT)) return -1; /* Add it at the end */ + min = 0; - max = descr->nb_items; - while (min != max) + max = descr->nb_items - 1; + while (min <= max) { index = (min + max) / 2; if (HAS_STRINGS(descr)) @@ -817,10 +818,10 @@ static INT LISTBOX_FindStringPos( LB_DESCR *descr, LPCWSTR str, BOOL exact ) res = SendMessageW( descr->owner, WM_COMPAREITEM, id, (LPARAM)&cis ); } if (!res) return index; - if (res > 0) max = index; + if (res > 0) max = index - 1; else min = index + 1; } - return exact ? -1 : max; + return exact ? -1 : min; } diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c index 69d3381cc9..9af675bd89 100644 --- a/dlls/comctl32/tests/listbox.c +++ b/dlls/comctl32/tests/listbox.c @@ -2032,7 +2032,7 @@ static void test_WM_MEASUREITEM(void) ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2"); ok(ret == 2, "expected 2, got %ld\n", ret); - ok_sequence(sequences, PARENT_SEQ_INDEX, lb_addstring_sort_parent_seq, "LB_ADDSTRING (LBS_SORT)", TRUE); + ok_sequence(sequences, PARENT_SEQ_INDEX, lb_addstring_sort_parent_seq, "LB_ADDSTRING (LBS_SORT)", FALSE); DestroyWindow(listbox); /* LBS_HASSTRINGS */ -- 2.18.0
Hi, While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=39560 Your paranoid android. === wvistau64 (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18 === wvistau64_zh_CN (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18 === wvistau64_fr (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18 === wvistau64_he (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18 === wvistau64 (64 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18 === w1064 (64 bit listbox) === The previous 1 run(s) terminated abnormally
Hi, While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=39559 Your paranoid android. === wvistau64 (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18 === wvistau64_zh_CN (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18 === wvistau64_fr (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18 === wvistau64_he (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18 === wvistau64 (64 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18
On 07/05/2018 08:18 AM, Marvin wrote:
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=39559
Your paranoid android.
=== wvistau64 (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18
=== wvistau64_zh_CN (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18
=== wvistau64_fr (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18
=== wvistau64_he (32 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18
=== wvistau64 (64 bit listbox) === listbox.c:1025: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) failed err 18 Same as the last time, it's unrelated and also does not show up on test.winehq.org.
participants (2)
-
Marvin -
Nikolay Sivov