[PATCH v2 1/8] riched20: Add destroy_para() helper.

Sergio Gómez Del Real sdelreal at codeweavers.com
Thu Nov 29 07:44:48 CST 2018


Signed-off-by: Sergio Gómez Del Real <sdelreal at codeweavers.com>
---
 dlls/riched20/editor.c |  5 ++++-
 dlls/riched20/editor.h |  1 +
 dlls/riched20/list.c   |  6 ------
 dlls/riched20/para.c   | 11 ++++++++++-
 4 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 2571ce97bc..d79888b933 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3164,7 +3164,10 @@ void ME_DestroyEditor(ME_TextEditor *editor)
   ME_EmptyUndoStack(editor);
   while(p) {
     pNext = p->next;
-    ME_DestroyDisplayItem(p);
+    if (p->type == diParagraph)
+      destroy_para(editor, p);
+    else
+      ME_DestroyDisplayItem(p);
     p = pNext;
   }
 
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index eba6d35fc7..e1a002bfaa 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -77,6 +77,7 @@ ME_DisplayItem *ME_FindItemBackOrHere(ME_DisplayItem *di, ME_DIType nTypeOrClass
 ME_DisplayItem *ME_MakeDI(ME_DIType type) DECLSPEC_HIDDEN;
 void ME_DestroyDisplayItem(ME_DisplayItem *item) DECLSPEC_HIDDEN;
 void ME_DumpDocument(ME_TextBuffer *buffer) DECLSPEC_HIDDEN;
+void destroy_para(ME_TextEditor *editor, ME_DisplayItem *item) DECLSPEC_HIDDEN;
 
 /* string.c */
 ME_String *ME_MakeStringN(LPCWSTR szText, int nMaxChars) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/list.c b/dlls/riched20/list.c
index ba35a90a98..23d1a38991 100644
--- a/dlls/riched20/list.c
+++ b/dlls/riched20/list.c
@@ -161,12 +161,6 @@ void ME_DestroyDisplayItem(ME_DisplayItem *item)
 {
   if (0)
     TRACE("type=%s\n", ME_GetDITypeName(item->type));
-  if (item->type==diParagraph)
-  {
-    ME_DestroyString(item->member.para.text);
-    para_num_clear( &item->member.para.para_num );
-  }
-
   if (item->type==diRun)
   {
     if (item->member.run.reobj)
diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c
index fcd7936807..3d86734aa1 100644
--- a/dlls/riched20/para.c
+++ b/dlls/riched20/para.c
@@ -32,6 +32,15 @@ static ME_DisplayItem *make_para(ME_TextEditor *editor)
     return item;
 }
 
+void destroy_para(ME_TextEditor *editor, ME_DisplayItem *item)
+{
+    assert(item->type == diParagraph);
+
+    ME_DestroyString(item->member.para.text);
+    para_num_clear( &item->member.para.para_num );
+    ME_DestroyDisplayItem(item);
+}
+
 void ME_MakeFirstParagraph(ME_TextEditor *editor)
 {
   ME_Context c;
@@ -682,7 +691,7 @@ ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp,
   tp->member.para.next_para = pNext->member.para.next_para;
   pNext->member.para.next_para->member.para.prev_para = tp;
   ME_Remove(pNext);
-  ME_DestroyDisplayItem(pNext);
+  destroy_para(editor, pNext);
 
   ME_PropagateCharOffset(tp->member.para.next_para, -end_len);
 
-- 
2.17.1




More information about the wine-devel mailing list