From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/editor.c | 7 +++---- dlls/riched20/editor.h | 2 +- dlls/riched20/para.c | 2 +- dlls/riched20/reader.c | 2 +- dlls/riched20/run.c | 3 +-- dlls/riched20/style.c | 13 ++++++------- dlls/riched20/undo.c | 3 +-- 7 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 3628e51ac9b..f7106512705 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -1524,8 +1524,7 @@ static void ME_RTFReadHook(RTF_Info *info) { case rtfBeginGroup: if (info->stackTop < maxStack) { - info->stack[info->stackTop].style = info->style; - ME_AddRefStyle(info->style); + info->stack[info->stackTop].style = style_add_ref(info->style); info->stack[info->stackTop].codePage = info->codePage; info->stack[info->stackTop].unicodeLength = info->unicodeLength; } @@ -1608,7 +1607,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre else { style = editor->pBuffer->pDefaultStyle; - ME_AddRefStyle(style); + style_add_ref(style); set_selection_cursors(editor, 0, 0); ME_InternalDeleteText(editor, &editor->pCursors[1], ME_GetTextLength(editor), FALSE); @@ -4189,7 +4188,7 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, editor->pCursors[1] = editor->pCursors[0]; /* plain text can only have the default style. */ ME_ClearTempStyle(editor); - ME_AddRefStyle(editor->pBuffer->pDefaultStyle); + style_add_ref(editor->pBuffer->pDefaultStyle); ME_ReleaseStyle( editor->pCursors[0].run->style ); editor->pCursors[0].run->style = editor->pBuffer->pDefaultStyle; } diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 3028d9bdbd5..e3f196c8bdc 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -49,7 +49,7 @@ static inline const char *debugstr_run( const ME_Run *run ) /* style.c */ ME_Style *style_get_insert_style( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN; ME_Style *ME_MakeStyle(CHARFORMAT2W *style) DECLSPEC_HIDDEN; -void ME_AddRefStyle(ME_Style *item) DECLSPEC_HIDDEN; +ME_Style *style_add_ref( ME_Style *item ) DECLSPEC_HIDDEN; void ME_DestroyStyle(ME_Style *item) DECLSPEC_HIDDEN; void ME_ReleaseStyle(ME_Style *item) DECLSPEC_HIDDEN; ME_Style *ME_ApplyStyle(ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style) DECLSPEC_HIDDEN; diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index 166b1fcd45b..79788c09a02 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -412,7 +412,7 @@ void para_num_init( ME_Context *c, ME_Paragraph *para ) } else { - ME_AddRefStyle( style ); + style_add_ref( style ); }
para->para_num.style = style; diff --git a/dlls/riched20/reader.c b/dlls/riched20/reader.c index b17d6835f25..22986d31fe3 100644 --- a/dlls/riched20/reader.c +++ b/dlls/riched20/reader.c @@ -445,7 +445,7 @@ static void RTFUngetToken(RTF_Info *info) if(RTFCheckCM (info, rtfGroup, rtfEndGroup)) { info->stack[info->stackTop].style = info->style; - ME_AddRefStyle(info->style); + style_add_ref(info->style); info->stackTop++; } } diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c index f6e6f08d12a..2fc498571b8 100644 --- a/dlls/riched20/run.c +++ b/dlls/riched20/run.c @@ -347,8 +347,7 @@ ME_Run *run_create( ME_Style *s, int flags )
if (!item) return NULL;
- ME_AddRefStyle( s ); - run->style = s; + run->style = style_add_ref( s ); run->reobj = NULL; run->nFlags = flags; run->nCharOfs = -1; diff --git a/dlls/riched20/style.c b/dlls/riched20/style.c index 9c9b5cbb4e0..1e57b87d948 100644 --- a/dlls/riched20/style.c +++ b/dlls/riched20/style.c @@ -215,8 +215,7 @@ ME_Style *ME_ApplyStyle(ME_TextEditor *editor, ME_Style *sSrc, CHARFORMAT2W *mod if (!memcmp( &s->fmt, &fmt, sizeof(fmt) )) { TRACE_(richedit_style)("found existing style %p\n", s); - ME_AddRefStyle( s ); - return s; + return style_add_ref( s ); } }
@@ -451,12 +450,13 @@ void ME_DestroyStyle(ME_Style *s) heap_free(s); }
-void ME_AddRefStyle(ME_Style *s) +ME_Style *style_add_ref( ME_Style *s ) { assert(s->nRefs>0); /* style with 0 references isn't supposed to exist */ s->nRefs++; all_refs++; - TRACE_(richedit_style)("ME_AddRefStyle %p, new refs=%d, total refs=%d\n", s, s->nRefs, all_refs); + TRACE_(richedit_style)( "style %p, new refs %d, total refs %d.\n", s, s->nRefs, all_refs ); + return s; }
void ME_ReleaseStyle(ME_Style *s) @@ -491,15 +491,14 @@ ME_Style *style_get_insert_style( ME_TextEditor *editor, ME_Cursor *cursor ) else style = cursor->run->style;
- ME_AddRefStyle( style ); - return style; + return style_add_ref( style ); }
void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style) { ME_Style *old_style = editor->pBuffer->pCharStyle;
- if (style) ME_AddRefStyle( style ); + if (style) style_add_ref( style ); editor->pBuffer->pCharStyle = style; if (old_style) ME_ReleaseStyle( old_style ); } diff --git a/dlls/riched20/undo.c b/dlls/riched20/undo.c index d95ce121234..e500a3e704d 100644 --- a/dlls/riched20/undo.c +++ b/dlls/riched20/undo.c @@ -144,8 +144,7 @@ BOOL add_undo_insert_run( ME_TextEditor *editor, int pos, const WCHAR *str, int undo->u.insert_run.pos = pos; undo->u.insert_run.len = len; undo->u.insert_run.flags = flags; - undo->u.insert_run.style = style; - ME_AddRefStyle( style ); + undo->u.insert_run.style = style_add_ref( style ); return TRUE; }