From 70705c7db0ea9b411c0ce54dce6e96429d4b1848 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 8 May 2023 19:34:43 +0800 Subject: [PATCH] fix bug reported in Issue #116 --- src/kernel/desktop-ths.c | 14 ++++++++++++-- src/kernel/init.c | 13 ------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/kernel/desktop-ths.c b/src/kernel/desktop-ths.c index 954584b3..402714b7 100644 --- a/src/kernel/desktop-ths.c +++ b/src/kernel/desktop-ths.c @@ -141,6 +141,14 @@ BOOL mg_InitDesktop (void) #include "debug.h" +static IDLEHANDLER std_idle_handler; + +static BOOL idle_handler_for_desktop_thread (MSGQUEUE *msg_queue, BOOL wait) +{ + __mg_update_tick_count (NULL); + return std_idle_handler (msg_queue, wait); +} + void* __kernel_desktop_main (void* data) { MSG Msg; @@ -152,8 +160,10 @@ void* __kernel_desktop_main (void* data) return NULL; } - /* for threads mode, the idle handler for desktop thread is NULL */ - __mg_dsk_msg_queue->OnIdle = NULL; + /* For bug reported in Issue #116, under threads mode, the idle handler + for the desktop thread should call __mg_update_tick_count () */ + std_idle_handler = __mg_dsk_msg_queue->OnIdle; + __mg_dsk_msg_queue->OnIdle = idle_handler_for_desktop_thread; /* init desktop window */ init_desktop_win (); diff --git a/src/kernel/init.c b/src/kernel/init.c index ded7aaf9..f6a822ea 100644 --- a/src/kernel/init.c +++ b/src/kernel/init.c @@ -391,14 +391,6 @@ static BOOL InstallSEGVHandler (void) #include #endif -static IDLEHANDLER std_idle_handler; - -static BOOL idle_handler_for_main_thread (MSGQUEUE *msg_queue, BOOL wait) -{ - __mg_update_tick_count (NULL); - return std_idle_handler (msg_queue, wait); -} - int GUIAPI InitGUI (int args, const char *agr[]) { char engine [LEN_ENGINE_NAME + 1]; @@ -583,11 +575,6 @@ int GUIAPI InitGUI (int args, const char *agr[]) goto failure; } - /* for threads mode, the idle handler for the main threads should - call __mg_update_tick_count () */ - std_idle_handler = msg_queue->OnIdle; - msg_queue->OnIdle = idle_handler_for_main_thread; - /* init timer for tick counter */ step++; if (!mg_InitTimer (FALSE)) {