Jinoh Kang : riched20: Factor out undo-ignored status check.

Alexandre Julliard julliard at winehq.org
Thu Jul 14 16:59:25 CDT 2022


Module: wine
Branch: master
Commit: 0cd86e010e41eebdc1a4c142f9cc6a4948554d0e
URL:    https://gitlab.winehq.org/wine/wine/-/commit/0cd86e010e41eebdc1a4c142f9cc6a4948554d0e

Author: Jinoh Kang <jinoh.kang.kr at gmail.com>
Date:   Tue Jun 28 00:23:44 2022 +0900

riched20: Factor out undo-ignored status check.

Signed-off-by: Jinoh Kang <jinoh.kang.kr at gmail.com>

---

 dlls/riched20/editor.h |  5 +++++
 dlls/riched20/undo.c   | 16 ++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 3028d9bdbd5..4e8445c99aa 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -394,6 +394,11 @@ BOOL ME_Undo(ME_TextEditor *editor) DECLSPEC_HIDDEN;
 BOOL ME_Redo(ME_TextEditor *editor) DECLSPEC_HIDDEN;
 void ME_EmptyUndoStack(ME_TextEditor *editor) DECLSPEC_HIDDEN;
 
+static inline BOOL editor_undo_ignored(ME_TextEditor *editor)
+{
+    return editor->nUndoMode == umIgnore;
+}
+
 /* txtsrv.c */
 HRESULT create_text_services( IUnknown *outer, ITextHost *text_host, IUnknown **unk, BOOL emulate_10 ) DECLSPEC_HIDDEN;
 #ifdef __ASM_USE_THISCALL_WRAPPER
diff --git a/dlls/riched20/undo.c b/dlls/riched20/undo.c
index d95ce121234..607f90130d5 100644
--- a/dlls/riched20/undo.c
+++ b/dlls/riched20/undo.c
@@ -53,7 +53,7 @@ static void empty_redo_stack(ME_TextEditor *editor)
 void ME_EmptyUndoStack(ME_TextEditor *editor)
 {
   struct undo_item *cursor, *cursor2;
-  if (editor->nUndoMode == umIgnore)
+  if (editor->nUndoMode == umIgnore)  /* NOTE don't use editor_undo_ignored() here! */
     return;
   
   TRACE("Emptying undo stack\n");
@@ -74,7 +74,7 @@ static struct undo_item *add_undo( ME_TextEditor *editor, enum undo_type type )
     struct undo_item *undo, *item;
     struct list *head;
 
-    if (editor->nUndoMode == umIgnore) return NULL;
+    if (editor_undo_ignored(editor)) return NULL;
     if (editor->nUndoLimit == 0) return NULL;
 
     undo = heap_alloc( sizeof(*undo) );
@@ -229,7 +229,7 @@ void ME_CommitUndo(ME_TextEditor *editor)
   struct undo_item *item;
   struct list *head;
 
-  if (editor->nUndoMode == umIgnore)
+  if (editor_undo_ignored(editor))
     return;
   
   assert(editor->nUndoMode == umAddToUndo);
@@ -267,7 +267,7 @@ void ME_ContinueCoalescingTransaction(ME_TextEditor *editor)
   struct undo_item *item;
   struct list *head;
 
-  if (editor->nUndoMode == umIgnore)
+  if (editor_undo_ignored(editor))
     return;
 
   assert(editor->nUndoMode == umAddToUndo);
@@ -303,7 +303,7 @@ void ME_CommitCoalescingUndo(ME_TextEditor *editor)
   struct undo_item *item;
   struct list *head;
 
-  if (editor->nUndoMode == umIgnore)
+  if (editor_undo_ignored(editor))
     return;
 
   assert(editor->nUndoMode == umAddToUndo);
@@ -323,7 +323,7 @@ void ME_CommitCoalescingUndo(ME_TextEditor *editor)
 static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
 {
 
-  if (editor->nUndoMode == umIgnore)
+  if (editor_undo_ignored(editor))
     return;
   TRACE("Playing undo/redo item, id=%d\n", undo->type);
 
@@ -413,7 +413,7 @@ BOOL ME_Undo(ME_TextEditor *editor)
   struct list *head;
   struct undo_item *undo, *cursor2;
 
-  if (editor->nUndoMode == umIgnore) return FALSE;
+  if (editor_undo_ignored(editor)) return FALSE;
   assert(nMode == umAddToUndo || nMode == umIgnore);
 
   head = list_head( &editor->undo_stack );
@@ -453,7 +453,7 @@ BOOL ME_Redo(ME_TextEditor *editor)
 
   assert(nMode == umAddToUndo || nMode == umIgnore);
   
-  if (editor->nUndoMode == umIgnore) return FALSE;
+  if (editor_undo_ignored(editor)) return FALSE;
 
   head = list_head( &editor->redo_stack );
   if (!head) return FALSE;




More information about the wine-cvs mailing list