From a7cfd2102032e6da541a4f7799b36b38ddd1cc17 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sat, 29 Feb 2020 16:07:34 +0800 Subject: [PATCH] fix a bug in travel_all_hosted: duplicated calling of callback; tune travel_all_hosted: use breadth first traveling policy due to overflow of the post message queue; tune format --- src/kernel/message.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/kernel/message.c b/src/kernel/message.c index df0da709..6af1255f 100644 --- a/src/kernel/message.c +++ b/src/kernel/message.c @@ -636,13 +636,11 @@ static void travel_all_hosted (PMAINWIN pWin, { PMAINWIN pNext = pWin->pFirstHosted; while (pNext) { - travel_all_hosted (pNext, cb, data); - cb (pNext, data); + + travel_all_hosted (pNext, cb, data); pNext = pNext->pNextHosted; } - - cb (pWin, data); } static void _my_travel_cb (PMAINWIN win, void* data) @@ -661,6 +659,7 @@ int __mg_broadcast_message (PMSGQUEUE msg_queue, MSG* msg) msg->time = 0; if ((win = msg_queue->pRootMainWin)) { + _my_travel_cb (win, msg); travel_all_hosted (win, _my_travel_cb, msg); } @@ -796,12 +795,12 @@ checkagain: *pMsg = pMsgQueue->pFirstSyncMsg->Msg; SET_PADD (pMsgQueue->pFirstSyncMsg); if (IS_MSG_WANTED(pMsg->message)) { - if (uRemoveMsg == PM_REMOVE) { - pMsgQueue->pFirstSyncMsg = pMsgQueue->pFirstSyncMsg->pNext; - } + if (uRemoveMsg == PM_REMOVE) { + pMsgQueue->pFirstSyncMsg = pMsgQueue->pFirstSyncMsg->pNext; + } - UNLOCK_MSGQ (pMsgQueue); - return TRUE; + UNLOCK_MSGQ (pMsgQueue); + return TRUE; } } else @@ -816,13 +815,13 @@ checkagain: SET_PADD (NULL); if (IS_MSG_WANTED(pMsg->message)) { - if (uRemoveMsg == PM_REMOVE) { - pMsgQueue->pFirstNotifyMsg = phead->next; - FREEQMSG (phead); - } + if (uRemoveMsg == PM_REMOVE) { + pMsgQueue->pFirstNotifyMsg = phead->next; + FREEQMSG (phead); + } - UNLOCK_MSGQ (pMsgQueue); - return TRUE; + UNLOCK_MSGQ (pMsgQueue); + return TRUE; } } else @@ -851,7 +850,6 @@ checkagain: /* * check invalidate region of the windows */ - if (pMsgQueue->dwState & QS_PAINT && IS_MSG_WANTED(MSG_PAINT)) { PMAINWIN pHostingRoot; HWND hNeedPaint; @@ -879,11 +877,7 @@ checkagain: pMsg->lParam = 0; SET_PADD (NULL); -#if 0 //ndef _MGHAVE_VIRTUAL_WINDOW - pHostingRoot = __mg_dsk_win; -#else pHostingRoot = pMsgQueue->pRootMainWin; -#endif if ((hNeedPaint = msgCheckHostedTree (pHostingRoot))) { pMsg->hwnd = hNeedPaint;