Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- 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 c8903e26f6..114d842759 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -1264,8 +1264,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; @@ -1306,8 +1304,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)) { @@ -1323,7 +1319,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; @@ -5205,7 +5200,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 783ced66c9..9372c484af 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -2786,12 +2786,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);
@@ -2802,15 +2800,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);