Commit 114a64ce authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Added missing style releases.

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.
parent fc618ab0
......@@ -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);
}
......
......@@ -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
......
......@@ -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)
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment