Module: wine
Branch: master
Commit: e7f725ec5f641fbb425bb44cbfa17b6cd5de5da9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e7f725ec5f641fbb425bb44cb…
Author: Aric Stewart <aric(a)codeweavers.com>
Date: Fri Feb 12 09:31:11 2016 -0600
imm32: Detach hMsgBuf when sending messages in ImmGenerateMessage.
The issues is that if a message being sent in ImmGenerateMessage gets
turned around and sent into an IME that in response to that message
calls ImmGenerateMessage, the hMsgBuf still has the old message in it
and it ends up getting processed in a loop again and again.
Signed-off-by: Aric Stewart <aric(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/imm32/imm.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index 2d08378..af47470 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -2893,15 +2893,23 @@ BOOL WINAPI ImmGenerateMessage(HIMC hIMC)
if (data->IMC.dwNumMsgBuf > 0)
{
LPTRANSMSG lpTransMsg;
- DWORD i;
+ HIMCC hMsgBuf;
+ DWORD i, dwNumMsgBuf;
- lpTransMsg = ImmLockIMCC(data->IMC.hMsgBuf);
- for (i = 0; i < data->IMC.dwNumMsgBuf; i++)
- ImmInternalSendIMEMessage(data, lpTransMsg[i].message, lpTransMsg[i].wParam, lpTransMsg[i].lParam);
-
- ImmUnlockIMCC(data->IMC.hMsgBuf);
+ /* We are going to detach our hMsgBuff so that if processing messages
+ generates new messages they go into a new buffer */
+ hMsgBuf = data->IMC.hMsgBuf;
+ dwNumMsgBuf = data->IMC.dwNumMsgBuf;
+ data->IMC.hMsgBuf = ImmCreateIMCC(0);
data->IMC.dwNumMsgBuf = 0;
+
+ lpTransMsg = ImmLockIMCC(hMsgBuf);
+ for (i = 0; i < dwNumMsgBuf; i++)
+ ImmInternalSendIMEMessage(data, lpTransMsg[i].message, lpTransMsg[i].wParam, lpTransMsg[i].lParam);
+
+ ImmUnlockIMCC(hMsgBuf);
+ ImmDestroyIMCC(hMsgBuf);
}
return TRUE;