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) ...@@ -475,7 +475,7 @@ void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor)
di = ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, pStyle, di = ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, pStyle,
MERF_ENDROW); MERF_ENDROW);
ME_SendSelChange(editor); ME_ReleaseStyle(pStyle);
} }
......
...@@ -1355,15 +1355,13 @@ static void ME_RTFReadHook(RTF_Info *info) ...@@ -1355,15 +1355,13 @@ static void ME_RTFReadHook(RTF_Info *info)
{ {
RTFFlushOutputBuffer(info); RTFFlushOutputBuffer(info);
info->stackTop--; info->stackTop--;
if (info->stackTop<=0) { if (info->stackTop <= 0)
info->rtfClass = rtfEOF; info->rtfClass = rtfEOF;
if (info->stackTop < 0)
return; return;
}
assert(info->stackTop >= 0);
ME_ReleaseStyle(info->style); ME_ReleaseStyle(info->style);
info->style = info->stack[info->stackTop].style; info->style = info->stack[info->stackTop].style;
ME_AddRefStyle(info->style);
info->codePage = info->stack[info->stackTop].codePage; info->codePage = info->stack[info->stackTop].codePage;
info->unicodeLength = info->stack[info->stackTop].unicodeLength; info->unicodeLength = info->stack[info->stackTop].unicodeLength;
break; break;
...@@ -1530,8 +1528,16 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre ...@@ -1530,8 +1528,16 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
if (parser.lpRichEditOle) if (parser.lpRichEditOle)
IRichEditOle_Release(parser.lpRichEditOle); IRichEditOle_Release(parser.lpRichEditOle);
if (!inStream.editstream->dwError && parser.stackTop > 0) if (parser.stackTop > 0)
inStream.editstream->dwError = HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); {
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 /* Remove last line break, as mandated by tests. This is not affected by
CR/LF counters, since RTF streaming presents only \para tokens, which CR/LF counters, since RTF streaming presents only \para tokens, which
......
...@@ -156,6 +156,7 @@ ME_Style *ME_MakeStyle(CHARFORMAT2W *style) { ...@@ -156,6 +156,7 @@ ME_Style *ME_MakeStyle(CHARFORMAT2W *style) {
s->hFont = NULL; s->hFont = NULL;
s->tm.tmAscent = -1; s->tm.tmAscent = -1;
all_refs++; all_refs++;
TRACE_(richedit_style)("ME_MakeStyle %p, total refs=%d\n", s, all_refs);
return s; return s;
} }
...@@ -449,6 +450,7 @@ void ME_AddRefStyle(ME_Style *s) ...@@ -449,6 +450,7 @@ void ME_AddRefStyle(ME_Style *s)
assert(s->nRefs>0); /* style with 0 references isn't supposed to exist */ assert(s->nRefs>0); /* style with 0 references isn't supposed to exist */
s->nRefs++; s->nRefs++;
all_refs++; 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) void ME_ReleaseStyle(ME_Style *s)
......
...@@ -70,6 +70,7 @@ static ME_DisplayItem* ME_InsertEndParaFromCursor(ME_TextEditor *editor, ...@@ -70,6 +70,7 @@ static ME_DisplayItem* ME_InsertEndParaFromCursor(ME_TextEditor *editor,
} }
tp = ME_SplitParagraph(editor, cursor->pRun, pStyle, eol_str, paraFlags); tp = ME_SplitParagraph(editor, cursor->pRun, pStyle, eol_str, paraFlags);
ME_ReleaseStyle(pStyle);
cursor->pPara = tp; cursor->pPara = tp;
cursor->pRun = ME_FindItemFwd(tp, diRun); cursor->pRun = ME_FindItemFwd(tp, diRun);
return tp; 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