riched20: Make ME_StreamIn create undos properly

Matt Finnicum mattfinn at gmail.com
Mon Nov 27 23:35:50 CST 2006


This fixes an occasional crash/assertion in richedit that has been
around for a while. It also fixes a conformance test. I also believe
it fixed bug 6005 but I'll wait for the submitter to check it since I
found testing it confusing.

Changelog:
Make ME_StreamIn create undos properly
---
 dlls/riched20/editor.c       |   20 ++++++++++----------
 dlls/riched20/tests/editor.c |    2 --
 2 files changed, 10 insertions(+), 12 deletions(-)
-------------- next part --------------
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 779a6bc..bb690b0 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -597,7 +597,7 @@ static LRESULT ME_StreamIn(ME_TextEditor
 {
   RTF_Info parser;
   ME_Style *style;
-  int from, to, to2, nUndoMode;
+  int from, to, to2;
   ME_UndoItem *pUI;
   int nEventMask = editor->nEventMask;
   ME_InStream inStream;
@@ -621,9 +621,6 @@ static LRESULT ME_StreamIn(ME_TextEditor
     /* FIXME restore default paragraph formatting ! */
   }
   
-  nUndoMode = editor->nUndoMode;
-  editor->nUndoMode = umIgnore;
-
   inStream.editstream = stream;
   inStream.editstream->dwError = 0;
   inStream.dwSize = 0;
@@ -675,16 +672,19 @@ static LRESULT ME_StreamIn(ME_TextEditor
       SendMessageA(editor->hWnd, EM_SETSEL, 0, 0);
   }
   
-  editor->nUndoMode = nUndoMode;
   if (format & SFF_SELECTION)
   {
-    pUI = ME_AddUndoItem(editor, diUndoDeleteRun, NULL);
-    TRACE("from %d to %d\n", from, to);
-    if (pUI && from < to)
+    if(from < to) /* selection overwritten is non-empty */
     {
-      pUI->nStart = from;
-      pUI->nLen = to-from;
+      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);
   }
   else
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 1625481..da6390f 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -1308,10 +1308,8 @@ static void test_EM_GETMODIFY(void)
   SendMessage(hwndRichEdit, EM_STREAMIN, 
               (WPARAM)(SF_TEXT), (LPARAM)&es);
   result = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
-  todo_wine {
   ok (result != 0,
       "EM_GETMODIFY returned zero, instead of non-zero for EM_STREAM\n");
-  }
 
   DestroyWindow(hwndRichEdit);
 }
-- 
1.4.4.1


More information about the wine-patches mailing list