Skip to content

Commit

Permalink
完善主循环的代码
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Mar 15, 2013
1 parent efe74bb commit 979d264
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/kernel/main.c
Expand Up @@ -335,12 +335,16 @@ static int
LCUIApp_RunTask( LCUI_App *app )
{
LCUI_Task *task;

Queue_Lock( &app->tasks );
task = Queue_Get( &app->tasks, 0 );
if( task == NULL ) {
Queue_Unlock( &app->tasks );
return -1;
}
Queue_DeletePointer( &app->tasks, 0 );
if( task->func == NULL ) {
Queue_Unlock( &app->tasks );
return -2;
}
/* 调用函数指针指向的函数,并传递参数 */
Expand All @@ -353,6 +357,7 @@ LCUIApp_RunTask( LCUI_App *app )
free( task->arg[1] );
}
free( task );
Queue_Unlock( &app->tasks );
return 0;
}

Expand Down Expand Up @@ -383,7 +388,10 @@ LCUI_MainLoop_Run( LCUI_MainLoop *loop )
}
}
#ifdef LCUI_BUILD_IN_WIN32
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) ) {
if( PeekMessage( &msg, Win32_GetSelfHWND(), 0, 0, PM_REMOVE) ) {
if (msg.message == WM_QUIT) {
break;
}
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
Expand Down
3 changes: 2 additions & 1 deletion src/output/win32.c
Expand Up @@ -102,7 +102,8 @@ Win32_LCUI_WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
Graph_Free( &graph );
return 0;
case WM_DESTROY:
PostQuitMessage (0) ;
PostQuitMessage(0);
LCUI_MainLoop_Quit(NULL);
return 0;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
Expand Down

0 comments on commit 979d264

Please sign in to comment.