Clinton Stimpson : riched20: Fix crash undoing a paste.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jan 12 05:39:09 CST 2007


Module: wine
Branch: master
Commit: a065d0f68da6dc98fdb85ad8c9ea1aa9897ea989
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a065d0f68da6dc98fdb85ad8c9ea1aa9897ea989

Author: Clinton Stimpson <cjstimpson at utwire.net>
Date:   Thu Jan 11 23:09:44 2007 -0700

riched20: Fix crash undoing a paste.

---

 dlls/riched20/editor.c       |   13 +------------
 dlls/riched20/tests/editor.c |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index c939c81..561574f 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -598,7 +598,6 @@ static LRESULT ME_StreamIn(ME_TextEditor
   RTF_Info parser;
   ME_Style *style;
   int from, to, to2;
-  ME_UndoItem *pUI;
   int nEventMask = editor->nEventMask;
   ME_InStream inStream;
 
@@ -671,19 +670,9 @@ static LRESULT ME_StreamIn(ME_TextEditor
     if (!(format & SFF_SELECTION))
       SendMessageA(editor->hWnd, EM_SETSEL, 0, 0);
   }
-  
+
   if (format & SFF_SELECTION)
   {
-    if(from < to) /* selection overwritten is non-empty */
-    {
-      pUI = ME_AddUndoItem(editor, diUndoDeleteRun, NULL);
-      TRACE("from %d to %d\n", from, to);
-      if (pUI)
-      {
-        pUI->nStart = from;
-        pUI->nLen = to-from;
-      }
-    }
     /* even if we didn't add an undo, we need to commit the ones added earlier */
     ME_CommitUndo(editor);
   }
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 687ab25..6bae95b 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -22,6 +22,7 @@
 #include <windows.h>
 #include <richedit.h>
 #include <time.h>
+#include <stdio.h>
 
 static HMODULE hmoduleRichEdit;
 
@@ -1386,6 +1387,41 @@ static void test_EM_EXSETSEL(void)
     DestroyWindow(hwndRichEdit);
 }
 
+static void test_WM_PASTE(void)
+{
+    int result;
+    char buffer[1024] = {0};
+    const char* text1 = "testing paste\r";
+    const char* text2 = "testing paste\r\rtesting paste";
+    const char* text3 = "testing paste\rpaste\rtesting paste";
+    HWND hwndRichEdit = new_richedit(NULL);
+
+    SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text1);
+    SendMessage(hwndRichEdit, EM_SETSEL, 0, 14);
+    SendMessage(hwndRichEdit, WM_CHAR, 3, 0);  /* ctrl-c */
+    SendMessage(hwndRichEdit, EM_SETSEL, 14, 14);
+    SendMessage(hwndRichEdit, WM_CHAR, 22, 0);  /* ctrl-v */
+    SendMessage(hwndRichEdit, WM_CHAR, 26, 0);  /* ctrl-z */
+    SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
+    result = strcmp(text1, buffer);
+    ok(result == 0,
+        "test paste: strcmp = %i\n", result);
+
+    SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text2);
+    SendMessage(hwndRichEdit, EM_SETSEL, 8, 13);
+    SendMessage(hwndRichEdit, WM_CHAR, 3, 0);  /* ctrl-c */
+    SendMessage(hwndRichEdit, EM_SETSEL, 14, 14);
+    SendMessage(hwndRichEdit, WM_CHAR, 22, 0);  /* ctrl-v */
+    SendMessage(hwndRichEdit, WM_CHAR, 26, 0);  /* ctrl-z */
+    SendMessage(hwndRichEdit, WM_CHAR, 25, 0);  /* ctrl-y */
+    SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
+    result = strcmp(buffer,text3);
+    ok(result == 0,
+        "test paste: strcmp = %i\n", result);
+
+    DestroyWindow(hwndRichEdit);
+}
+
 START_TEST( editor )
 {
   MSG msg;
@@ -1412,6 +1448,7 @@ START_TEST( editor )
   test_WM_SETFONT();
   test_EM_GETMODIFY();
   test_EM_EXSETSEL();
+  test_WM_PASTE();
 
   /* Set the environment variable WINETEST_RICHED20 to keep windows
    * responsive and open for 30 seconds. This is useful for debugging.




More information about the wine-cvs mailing list