Module: wine Branch: oldstable Commit: 8de00682805109b886417fd16e7f12e8e1648657 URL: https://source.winehq.org/git/wine.git/?a=commit;h=8de00682805109b886417fd16...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Dec 5 15:09:03 2017 +0300
user32/edit: Allow buffer access after EM_GETHANDLE.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit f62d8dc58fb3fb5f11a8ab55620ab9b2fbdaf967) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/user32/edit.c | 8 ++------ dlls/user32/tests/edit.c | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index 78d78ea..7746c1b 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -1263,8 +1263,6 @@ static inline void text_buffer_changed(EDITSTATE *es) */ static void EDIT_LockBuffer(EDITSTATE *es) { - if (es->hlocapp) return; - if (!es->text) {
if(!es->hloc32W) return; @@ -1305,8 +1303,6 @@ static void EDIT_LockBuffer(EDITSTATE *es) */ static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force) { - if (es->hlocapp) return; - /* Edit window might be already destroyed */ if(!IsWindow(es->hwndSelf)) { @@ -1322,7 +1318,6 @@ static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force) ERR("es->text == 0 ... please report\n"); return; } - if (force || (es->lock_count == 1)) { if (es->hloc32W) { UINT countA = 0; @@ -5202,7 +5197,8 @@ LRESULT EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, B break; }
- if (IsWindow(hwnd) && es) EDIT_UnlockBuffer(es, FALSE); + if (IsWindow(hwnd) && es && msg != EM_GETHANDLE) + EDIT_UnlockBuffer(es, FALSE);
TRACE("hwnd=%p msg=%x (%s) -- 0x%08lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), result);
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index d745023..031d875 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -2773,12 +2773,10 @@ static void test_EM_GETHANDLE(void)
/* See if WM_GETTEXTLENGTH/WM_GETTEXT still work. */ len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0); -todo_wine ok(len == lstrlenA(str1), "Unexpected text length %d.\n", len);
lstrcpyA(current, str0); r = SendMessageA(hEdit, WM_GETTEXT, sizeof(current), (LPARAM)current); -todo_wine ok((r == lstrlenA(str1)) && !lstrcmpA(current, str1), "Unexpected retval %d and text "%s" (expected %d and "%s")\n", r, current, lstrlenA(str1), str1);
@@ -2789,15 +2787,28 @@ todo_wine LocalUnlock(hmem);
len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0); -todo_wine - ok(len == lstrlenA(str1), "Unexpected text length %d.\n", len); + ok(len == lstrlenA(str1_1), "Unexpected text length %d.\n", len);
lstrcpyA(current, str0); r = SendMessageA(hEdit, WM_GETTEXT, sizeof(current), (LPARAM)current); -todo_wine ok((r == lstrlenA(str1_1)) && !lstrcmpA(current, str1_1), "Unexpected retval %d and text "%s" (expected %d and "%s")\n", r, current, lstrlenA(str1_1), str1_1);
+ /* See if WM_SETTEXT/EM_REPLACESEL work. */ + r = SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)str1); + ok(r, "Failed to set text.\n"); + + buffer = LocalLock(hmem); + ok(buffer != NULL && buffer[0] == '1', "Unexpected buffer contents\n"); + LocalUnlock(hmem); + + r = SendMessageA(hEdit, EM_REPLACESEL, 0, (LPARAM)str1_1); + ok(r, "Failed to replace selection.\n"); + + buffer = LocalLock(hmem); + ok(buffer != NULL && buffer[0] == '2', "Unexpected buffer contents\n"); + LocalUnlock(hmem); + /* use LocalAlloc first to get a different handle */ halloc = LocalAlloc(LMEM_MOVEABLE, 42); ok(halloc != NULL, "got %p (expected != NULL)\n", halloc);