Dylan Smith : richedit: Cannot undo setting of default character format.

Alexandre Julliard julliard at winehq.org
Mon Jul 14 05:57:10 CDT 2008


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

Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date:   Fri Jul 11 20:06:05 2008 -0400

richedit: Cannot undo setting of default character format.

This also reverts commit 2b52dd845097f16076c0185b02a003f63898dcab:
wordpad: Empty the richedit undo buffer on creation.

The reverted commit I created to fix an issue that only applied to Wine,
but it just masked the issue which was in richedit controls.  The
default character format was set in two places while wordpad was
starting up, and caused wordpad to have two undo items at startup.

---

 dlls/riched20/editstr.h      |    3 +--
 dlls/riched20/list.c         |    3 +--
 dlls/riched20/run.c          |    9 ---------
 dlls/riched20/tests/editor.c |    2 +-
 dlls/riched20/undo.c         |    6 ------
 programs/wordpad/wordpad.c   |    1 -
 6 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h
index f3e837e..81f4cc3 100644
--- a/dlls/riched20/editstr.h
+++ b/dlls/riched20/editstr.h
@@ -86,8 +86,7 @@ typedef enum {
   diUndoSetParagraphFormat, /* 15 */
   diUndoSetCharFormat, /* 16 */
   diUndoEndTransaction, /* 17 - marks the end of a group of changes for undo */
-  diUndoSetDefaultCharFormat, /* 18 */
-  diUndoPotentialEndTransaction, /* 19 - allows grouping typed chars for undo */
+  diUndoPotentialEndTransaction, /* 18 - allows grouping typed chars for undo */
 } ME_DIType;
 
 #define SELECTIONBAR_WIDTH 9
diff --git a/dlls/riched20/list.c b/dlls/riched20/list.c
index 60c49e3..0b14aec 100644
--- a/dlls/riched20/list.c
+++ b/dlls/riched20/list.c
@@ -119,7 +119,7 @@ void ME_DestroyDisplayItem(ME_DisplayItem *item) {
     ME_ReleaseStyle(item->member.run.style);
     ME_DestroyString(item->member.run.strText);
   }
-  if (item->type==diUndoSetCharFormat || item->type==diUndoSetDefaultCharFormat) {
+  if (item->type==diUndoSetCharFormat) {
     ME_ReleaseStyle(item->member.ustyle);
   }
   if (item->type==diUndoSplitParagraph)
@@ -175,7 +175,6 @@ const char *ME_GetDITypeName(ME_DIType type)
     case diUndoDeleteRun: return "diUndoDeleteRun";
     case diUndoJoinParagraphs: return "diJoinParagraphs";
     case diUndoSplitParagraph: return "diSplitParagraph";
-    case diUndoSetDefaultCharFormat: return "diUndoSetDefaultCharFormat";
     default: return "?";
   }
 }
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index 0028536..19ebf1b 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -832,17 +832,8 @@ void ME_SetCharFormat(ME_TextEditor *editor, int nOfs, int nChars, CHARFORMAT2W
 void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod)
 {
   ME_Style *style;
-  ME_UndoItem *undo;
 
-  /* FIXME: Should this be removed? It breaks a test. */
   assert(mod->cbSize == sizeof(CHARFORMAT2W));
-  undo = ME_AddUndoItem(editor, diUndoSetDefaultCharFormat, NULL);
-  if (undo) {
-    undo->nStart = -1;
-    undo->nLen = -1;
-    undo->di.member.ustyle = editor->pBuffer->pDefaultStyle;
-    ME_AddRefStyle(undo->di.member.ustyle);
-  }
   style = ME_ApplyStyle(editor->pBuffer->pDefaultStyle, mod);
   editor->pBuffer->pDefaultStyle->fmt = style->fmt;
   editor->pBuffer->pDefaultStyle->tm = style->tm;
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 6c8756c..8d22e85 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -614,7 +614,7 @@ static void test_EM_SETCHARFORMAT(void)
              (LPARAM) &cf2);
   ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
   rc = SendMessage(hwndRichEdit, EM_CANUNDO, 0, 0);
-  todo_wine ok(rc == FALSE, "Should not be able to undo here.\n");
+  ok(rc == FALSE, "Should not be able to undo here.\n");
   SendMessage(hwndRichEdit, EM_EMPTYUNDOBUFFER, 0, 0);
 
   /* A valid flag, CHARFORMAT2 structure minimally filled */
diff --git a/dlls/riched20/undo.c b/dlls/riched20/undo.c
index bf992ab..eaf1791 100644
--- a/dlls/riched20/undo.c
+++ b/dlls/riched20/undo.c
@@ -84,7 +84,6 @@ ME_UndoItem *ME_AddUndoItem(ME_TextEditor *editor, ME_DIType type, const ME_Disp
       else pItem->member.run.ole_obj = NULL;
       break;
     case diUndoSetCharFormat:
-    case diUndoSetDefaultCharFormat:
       break;
     case diUndoDeleteRun:
     case diUndoJoinParagraphs:
@@ -292,11 +291,6 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, ME_DisplayItem *pItem)
     ME_SetCharFormat(editor, pUItem->nStart, pUItem->nLen, &pItem->member.ustyle->fmt);
     break;
   }
-  case diUndoSetDefaultCharFormat:
-  {
-    ME_SetDefaultCharFormat(editor, &pItem->member.ustyle->fmt);
-    break;
-  }
   case diUndoInsertRun:
   {
     ME_InsertRun(editor, pItem->member.run.nCharOfs, pItem);
diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c
index 80638c8..6f3e41a 100644
--- a/programs/wordpad/wordpad.c
+++ b/programs/wordpad/wordpad.c
@@ -2532,7 +2532,6 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar
     set_caption(NULL);
     set_bar_states();
     set_fileformat(SF_RTF);
-    SendMessageW(hEditorWnd, EM_EMPTYUNDOBUFFER, 0, 0);
     hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_POPUP));
     get_default_printer_opts();
     target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]);




More information about the wine-cvs mailing list