riched20: Don't resend a partial chunk to the edit stream callback.
It's basically used as a boolean to terminate the writing process if it's set to zero.
This commit is contained in:
parent
cb1e856612
commit
2a5886974d
|
@ -3404,6 +3404,24 @@ static void test_WM_SETTEXT(void)
|
||||||
#undef TEST_SETTEXTW
|
#undef TEST_SETTEXTW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set *pcb to one to show that the remaining cb-1 bytes are not
|
||||||
|
resent to the callkack. */
|
||||||
|
static DWORD CALLBACK test_esCallback_written_1(DWORD_PTR dwCookie,
|
||||||
|
LPBYTE pbBuff,
|
||||||
|
LONG cb,
|
||||||
|
LONG *pcb)
|
||||||
|
{
|
||||||
|
char** str = (char**)dwCookie;
|
||||||
|
ok(cb == *pcb, "cb %d, *pcb %d\n", cb, *pcb);
|
||||||
|
*pcb = 0;
|
||||||
|
if (cb > 0) {
|
||||||
|
memcpy(*str, pbBuff, cb);
|
||||||
|
*str += cb;
|
||||||
|
*pcb = 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void test_EM_STREAMOUT(void)
|
static void test_EM_STREAMOUT(void)
|
||||||
{
|
{
|
||||||
HWND hwndRichEdit = new_richedit(NULL);
|
HWND hwndRichEdit = new_richedit(NULL);
|
||||||
|
@ -3452,6 +3470,19 @@ static void test_EM_STREAMOUT(void)
|
||||||
ok(strcmp(buf, TestItem3) == 0,
|
ok(strcmp(buf, TestItem3) == 0,
|
||||||
"streamed text different, got %s\n", buf);
|
"streamed text different, got %s\n", buf);
|
||||||
|
|
||||||
|
/* Use a callback that sets *pcb to one */
|
||||||
|
p = buf;
|
||||||
|
es.dwCookie = (DWORD_PTR)&p;
|
||||||
|
es.dwError = 0;
|
||||||
|
es.pfnCallback = test_esCallback_written_1;
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es);
|
||||||
|
r = strlen(buf);
|
||||||
|
ok(r == 14, "streamed text length is %d, expecting 14\n", r);
|
||||||
|
ok(strcmp(buf, TestItem3) == 0,
|
||||||
|
"streamed text different, got %s\n", buf);
|
||||||
|
|
||||||
|
|
||||||
DestroyWindow(hwndRichEdit);
|
DestroyWindow(hwndRichEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,29 +49,18 @@ ME_StreamOutInit(ME_TextEditor *editor, EDITSTREAM *stream)
|
||||||
static BOOL
|
static BOOL
|
||||||
ME_StreamOutFlush(ME_OutStream *pStream)
|
ME_StreamOutFlush(ME_OutStream *pStream)
|
||||||
{
|
{
|
||||||
LONG nStart = 0;
|
|
||||||
LONG nWritten = 0;
|
LONG nWritten = 0;
|
||||||
LONG nRemaining = 0;
|
|
||||||
EDITSTREAM *stream = pStream->stream;
|
EDITSTREAM *stream = pStream->stream;
|
||||||
|
|
||||||
while (nStart < pStream->pos) {
|
if (pStream->pos) {
|
||||||
TRACE("sending %u bytes\n", pStream->pos - nStart);
|
TRACE("sending %u bytes\n", pStream->pos);
|
||||||
/* Some apps seem not to set *pcb unless a problem arises, relying
|
nWritten = pStream->pos;
|
||||||
on initial random nWritten value, which is usually >STREAMOUT_BUFFER_SIZE */
|
stream->dwError = stream->pfnCallback(stream->dwCookie, (LPBYTE)pStream->buffer,
|
||||||
nRemaining = pStream->pos - nStart;
|
pStream->pos, &nWritten);
|
||||||
nWritten = 0xDEADBEEF;
|
|
||||||
stream->dwError = stream->pfnCallback(stream->dwCookie, (LPBYTE)pStream->buffer + nStart,
|
|
||||||
pStream->pos - nStart, &nWritten);
|
|
||||||
TRACE("error=%u written=%u\n", stream->dwError, nWritten);
|
TRACE("error=%u written=%u\n", stream->dwError, nWritten);
|
||||||
if (nWritten > (pStream->pos - nStart) || nWritten<0) {
|
|
||||||
FIXME("Invalid returned written size *pcb: 0x%x (%d) instead of %d\n",
|
|
||||||
(unsigned)nWritten, nWritten, nRemaining);
|
|
||||||
nWritten = nRemaining;
|
|
||||||
}
|
|
||||||
if (nWritten == 0 || stream->dwError)
|
if (nWritten == 0 || stream->dwError)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
pStream->written += nWritten;
|
/* Don't resend partial chunks if nWritten < pStream->pos */
|
||||||
nStart += nWritten;
|
|
||||||
}
|
}
|
||||||
pStream->pos = 0;
|
pStream->pos = 0;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in New Issue