richedit: Added missing style releases.
Dylan Smith
dylan.ah.smith at gmail.com
Mon Aug 10 09:53:53 CDT 2009
Style objects are referenced counted in richedit controls, so I tried to
make sure styles were released properly. This can be checked using with
the all_refs global reference count to see if everything is cleaned up.
---
dlls/riched20/caret.c | 2 +-
dlls/riched20/editor.c | 18 ++++++++++++------
dlls/riched20/style.c | 2 ++
dlls/riched20/table.c | 1 +
4 files changed, 16 insertions(+), 7 deletions(-)
-------------- next part --------------
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 058d278..ca34977 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -475,7 +475,7 @@ void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor)
di = ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, pStyle,
MERF_ENDROW);
- ME_SendSelChange(editor);
+ ME_ReleaseStyle(pStyle);
}
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index b08c238..2b6f61f 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1355,15 +1355,13 @@ static void ME_RTFReadHook(RTF_Info *info)
{
RTFFlushOutputBuffer(info);
info->stackTop--;
- if (info->stackTop<=0) {
+ if (info->stackTop <= 0)
info->rtfClass = rtfEOF;
+ if (info->stackTop < 0)
return;
- }
- assert(info->stackTop >= 0);
ME_ReleaseStyle(info->style);
info->style = info->stack[info->stackTop].style;
- ME_AddRefStyle(info->style);
info->codePage = info->stack[info->stackTop].codePage;
info->unicodeLength = info->stack[info->stackTop].unicodeLength;
break;
@@ -1530,8 +1528,16 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
if (parser.lpRichEditOle)
IRichEditOle_Release(parser.lpRichEditOle);
- if (!inStream.editstream->dwError && parser.stackTop > 0)
- inStream.editstream->dwError = HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
+ if (parser.stackTop > 0)
+ {
+ while (--parser.stackTop >= 0)
+ {
+ ME_ReleaseStyle(parser.style);
+ parser.style = parser.stack[parser.stackTop].style;
+ }
+ if (!inStream.editstream->dwError)
+ inStream.editstream->dwError = HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
+ }
/* Remove last line break, as mandated by tests. This is not affected by
CR/LF counters, since RTF streaming presents only \para tokens, which
diff --git a/dlls/riched20/style.c b/dlls/riched20/style.c
index a3b532e..a479c0a 100644
--- a/dlls/riched20/style.c
+++ b/dlls/riched20/style.c
@@ -156,6 +156,7 @@ ME_Style *ME_MakeStyle(CHARFORMAT2W *style) {
s->hFont = NULL;
s->tm.tmAscent = -1;
all_refs++;
+ TRACE_(richedit_style)("ME_MakeStyle %p, total refs=%d\n", s, all_refs);
return s;
}
@@ -449,6 +450,7 @@ void ME_AddRefStyle(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);
}
void ME_ReleaseStyle(ME_Style *s)
diff --git a/dlls/riched20/table.c b/dlls/riched20/table.c
index 6c8ca76..69f4851 100644
--- a/dlls/riched20/table.c
+++ b/dlls/riched20/table.c
@@ -70,6 +70,7 @@ static ME_DisplayItem* ME_InsertEndParaFromCursor(ME_TextEditor *editor,
}
tp = ME_SplitParagraph(editor, cursor->pRun, pStyle, eol_str, paraFlags);
+ ME_ReleaseStyle(pStyle);
cursor->pPara = tp;
cursor->pRun = ME_FindItemFwd(tp, diRun);
return tp;
More information about the wine-patches
mailing list