Nikolay Sivov : user32/edit: Allow buffer access after EM_GETHANDLE.
Alexandre Julliard
julliard at winehq.org
Tue Dec 5 15:02:13 CST 2017
Module: wine
Branch: master
Commit: f62d8dc58fb3fb5f11a8ab55620ab9b2fbdaf967
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f62d8dc58fb3fb5f11a8ab55620ab9b2fbdaf967
Author: Nikolay Sivov <nsivov at 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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at 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 c8903e2..114d842 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 783ced6..9372c48 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);
More information about the wine-cvs
mailing list