user32: After handling an internal message give a chance to real message to arrive.

Dmitry Timoshkov dmitry at baikal.ru
Thu Apr 23 02:23:31 CDT 2015


---
 dlls/user32/message.c   | 12 +++++++++++-
 dlls/user32/tests/msg.c | 10 +++-------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index 2b544de..4650ef1 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -2931,7 +2931,10 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags
                 else
                     peek_message( msg, info.msg.hwnd, info.msg.message,
                                   info.msg.message, flags | PM_REMOVE, changed_mask );
-                continue;
+
+                /* give a chance to real message to arrive */
+                HeapFree( GetProcessHeap(), 0, buffer );
+                return FALSE;
             }
 	    if (info.msg.message >= WM_DDE_FIRST && info.msg.message <= WM_DDE_LAST)
 	    {
@@ -2958,6 +2961,13 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags
         reply_message( &info, result, TRUE );
         thread_info->receive_info = old_info;
 
+        if (info.msg.message & 0x80000000)  /* internal message */
+        {
+            /* give a chance to real message to arrive */
+            HeapFree( GetProcessHeap(), 0, buffer );
+            return FALSE;
+        }
+
         /* if some PM_QS* flags were specified, only handle sent messages from now on */
         if (HIWORD(flags) && !changed_mask) flags = PM_QS_SENDMESSAGE | LOWORD(flags);
     }
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 50e1e2b..acaad2d 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -14705,7 +14705,7 @@ static void test_SendMessage_other_thread(int thread_n)
     GetMessageA(&msg, 0, 0, 0);
     ok(msg.message == WM_USER, "expected WM_USER, got %04x\n", msg.message);
     DispatchMessageA(&msg);
-    ok_sequence(send_message_1, "SendMessage from other thread 1", thread_n == 2);
+    ok_sequence(send_message_1, "SendMessage from other thread 1", FALSE);
 
     /* intentionally yield */
     MsgWaitForMultipleObjects(0, NULL, FALSE, 100, qs_all_input);
@@ -14720,7 +14720,7 @@ static void test_SendMessage_other_thread(int thread_n)
     trace("main: call PeekMessage\n");
     ok(PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "PeekMessage should not fail\n");
     ok(msg.message == WM_USER+1, "expected WM_USER+1, got %04x\n", msg.message);
-    ok_sequence(send_message_3, "SendMessage from other thread 3", thread_n == 2);
+    ok_sequence(send_message_3, "SendMessage from other thread 3", FALSE);
 
     trace("main: call PeekMessage\n");
     ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "PeekMessage should not fail\n");
@@ -14732,15 +14732,11 @@ static void test_SendMessage_other_thread(int thread_n)
     MsgWaitForMultipleObjects(0, NULL, FALSE, 100, qs_all_input);
 
     ret = GetQueueStatus(QS_SENDMESSAGE|QS_POSTMESSAGE);
-    /* FIXME: remove once Wine is fixed */
-if (thread_n == 2) todo_wine
-    ok(ret == 0, "wrong status %08x\n", ret);
-else
     ok(ret == 0, "wrong status %08x\n", ret);
 
     trace("main: call PeekMessage\n");
     ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "PeekMessage should fail\n");
-    ok_sequence(WmEmptySeq, "SendMessage from other thread 5", thread_n == 2);
+    ok_sequence(WmEmptySeq, "SendMessage from other thread 5", FALSE);
 
     ret = GetQueueStatus(QS_SENDMESSAGE|QS_POSTMESSAGE);
     ok(ret == 0, "wrong status %08x\n", ret);
-- 
2.3.5




More information about the wine-patches mailing list