riched20: Add destroy_para() helper.

Signed-off-by: Sergio Gómez Del Real <sdelreal@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sergio Gómez Del Real 2018-11-29 08:44:48 -05:00 committed by Alexandre Julliard
parent 4e633f9244
commit 118908d0af
4 changed files with 15 additions and 8 deletions

View File

@ -3164,6 +3164,9 @@ void ME_DestroyEditor(ME_TextEditor *editor)
ME_EmptyUndoStack(editor);
while(p) {
pNext = p->next;
if (p->type == diParagraph)
destroy_para(editor, p);
else
ME_DestroyDisplayItem(p);
p = pNext;
}

View File

@ -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;

View File

@ -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)

View File

@ -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);