mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
Fix mainlop memory leak bug
This commit is contained in:
@@ -194,6 +194,8 @@ LCUI_API int LCUIMainLoop_Run( LCUI_MainLoop loop );
|
||||
/* 标记目标主循环需要退出 */
|
||||
LCUI_API void LCUIMainLoop_Quit( LCUI_MainLoop loop );
|
||||
|
||||
LCUI_API void LCUIMainLoop_Destroy( LCUI_MainLoop loop );
|
||||
|
||||
/* 检测LCUI是否活动 */
|
||||
LCUI_API LCUI_BOOL LCUI_IsActive( void );
|
||||
|
||||
|
||||
+15
-7
@@ -330,24 +330,27 @@ int LCUIMainLoop_Run( LCUI_MainLoop loop )
|
||||
}
|
||||
}
|
||||
loop->state = STATE_EXITED;
|
||||
DEBUG_MSG( "loop: %p, exit\n", loop );
|
||||
LCUIMainLoop_Destroy( loop );
|
||||
LinkedList_Delete( &MainApp.loops, 0 );
|
||||
/* 获取处于列表表头的主循环 */
|
||||
loop = LinkedList_Get( &MainApp.loops, 0 );
|
||||
if( loop ) {
|
||||
/* 改变当前运行的主循环 */
|
||||
MainApp.loop = loop;
|
||||
}
|
||||
DEBUG_MSG( "loop: %p, exit\n", loop );
|
||||
/* 改变当前运行的主循环 */
|
||||
MainApp.loop = loop;
|
||||
LCUICond_Broadcast( &MainApp.loop_changed );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** 标记目标主循环需要退出 */
|
||||
void LCUIMainLoop_Quit( LCUI_MainLoop loop )
|
||||
{
|
||||
loop->state = STATE_EXITED;
|
||||
}
|
||||
|
||||
void LCUIMainLoop_Destroy( LCUI_MainLoop loop )
|
||||
{
|
||||
free( loop );
|
||||
}
|
||||
|
||||
void LCUI_InitApp( LCUI_AppDriver app )
|
||||
{
|
||||
if( MainApp.driver_ready ) {
|
||||
@@ -372,6 +375,11 @@ void LCUI_InitApp( LCUI_AppDriver app )
|
||||
MainApp.driver_ready = TRUE;
|
||||
}
|
||||
|
||||
static void OnDeleteMainLoop( void *arg )
|
||||
{
|
||||
LCUIMainLoop_Destroy( arg );
|
||||
}
|
||||
|
||||
static void OnDeleteTask( void *arg )
|
||||
{
|
||||
LCUI_DeleteTask( arg );
|
||||
@@ -392,7 +400,7 @@ static void LCUI_ExitApp( void )
|
||||
LCUICond_Destroy( &MainApp.loop_changed );
|
||||
LCUIMutex_Destroy( &MainApp.tasks_mutex );
|
||||
LCUICond_Destroy( &MainApp.tasks_cond );
|
||||
LinkedList_Clear( &MainApp.loops, free );
|
||||
LinkedList_Clear( &MainApp.loops, OnDeleteMainLoop );
|
||||
LinkedList_Clear( &MainApp.tasks, OnDeleteTask );
|
||||
if( MainApp.driver_ready ) {
|
||||
LCUI_DestroyAppDriver( MainApp.driver );
|
||||
|
||||
Reference in New Issue
Block a user