tune order of terminating functions

This commit is contained in:
Vincent Wei
2020-02-26 23:02:24 +08:00
parent bdb4bbefe4
commit b9d71cd489
5 changed files with 29 additions and 29 deletions
+1 -1
View File
@@ -161,7 +161,7 @@ void mg_TerminateDesktop (void)
DestroyFreeClipRectList (&sg_FreeClipRectList);
DestroyFreeClipRectList (&sg_FreeInvRectList);
mg_TerminateSystemRes ();
//mg_TerminateSystemRes ();
//dongjunjie avoid double free
__mg_dsk_win = 0;
}
+1 -1
View File
@@ -207,7 +207,7 @@ void mg_TerminateDesktop (void)
// Since 5.0.0
__mg_free_hook_wins (0);
mg_TerminateSystemRes ();
// mg_TerminateSystemRes ();
// dongjunjie avoid double free
__mg_dsk_win = 0;
}
+12 -14
View File
@@ -121,18 +121,21 @@ int InitGUI (int argc, const char* agr[])
_ERR_PRINTF ("KERNEL>InitGUI: failed to initialize slice allocator!\n");
return step;
}
atexit (mg_TerminateSliceAllocator);
if (!mg_InitFixStr ()) {
err_message (step, "Can not initialize Fixed String heap!\n");
return step;
}
step++;
atexit (mg_TerminateFixStr);
if (!mg_InitMisc ()) {
err_message (step, "Can not initialize miscellous things!");
return step;
}
step++;
atexit (mg_TerminateMisc);
/* Init GAL engine. */
switch (mg_InitGAL (engine, mode)) {
@@ -176,9 +179,6 @@ int InitGUI (int argc, const char* agr[])
void TerminateGUI (int rcByGUI)
{
mg_TerminateMisc ();
mg_TerminateFixStr ();
mg_TerminateSliceAllocator();
}
#warning ExitGUISafely?
@@ -352,6 +352,7 @@ int InitGUI (int argc, const char* agr[])
return step;
}
step++;
atexit (mg_TerminateSliceAllocator);
if (!mg_InitFixStr ()) {
err_message (step, "Can not initialize Fixed String heap!\n");
@@ -434,16 +435,6 @@ int InitGUI (int argc, const char* agr[])
#endif
InstallSEGVHandler ();
/** initialize icon bitmap resource.*/
if (mg_InitSystemRes () == FALSE) {
_ERR_PRINTF ("KERNEL>IniGUI: init system res error!\n");
return step;
}
step++;
/* DK[11/29/10]: For fix bug 4440, avoid double free. */
/* atexit (mg_TerminateSystemRes);
*/
if (!mg_InitGDI ()) {
err_message (step, "Initialization of GDI resource failure!\n");
return step;
@@ -459,6 +450,14 @@ int InitGUI (int argc, const char* agr[])
step++;
atexit (mg_TerminateScreenDC);
/** initialize icon bitmap resource.*/
if (mg_InitSystemRes () == FALSE) {
_ERR_PRINTF ("KERNEL>IniGUI: init system res error!\n");
return step;
}
step++;
atexit (mg_TerminateSystemRes);
#if 0
g_rcScr.left = 0;
g_rcScr.top = 0;
@@ -623,7 +622,6 @@ void TerminateGUI (int rcByGUI)
deleteThreadInfoKey();
#endif
mg_TerminateSliceAllocator();
}
#endif /* ifndef _MG_MINIMALGDI */
+11 -10
View File
@@ -473,15 +473,6 @@ int GUIAPI InitGUI (int args, const char *agr[])
InstallSEGVHandler ();
#endif
/*
* Load system resource here.
*/
step++;
if (!mg_InitSystemRes ()) {
_ERR_PRINTF ("KERNEL>InitGUI: Can not init system resource!\n");
goto failure1;
}
/* Init GDI. */
step++;
if(!mg_InitGDI()) {
@@ -496,6 +487,15 @@ int GUIAPI InitGUI (int args, const char *agr[])
goto failure1;
}
/*
* Load system resource here.
*/
step++;
if (!mg_InitSystemRes ()) {
_ERR_PRINTF ("KERNEL>InitGUI: Can not init system resource!\n");
goto failure1;
}
__mg_license_create();
__mg_splash_draw_framework();
@@ -647,8 +647,9 @@ void GUIAPI TerminateGUI (int not_used)
mg_TerminateLWEvent ();
mg_TerminateScreenDC ();
mg_TerminateGDI ();
mg_TerminateLFManager ();
mg_TerminateSystemRes ();
mg_TerminateGDI ();
mg_TerminateGAL ();
#ifdef _MGHAVE_ADV_2DAPI
+4 -3
View File
@@ -455,9 +455,6 @@ void TerminateResManager()
{
int i;
/* Since 5.0.0, destroy the map for system bitmaps */
__mg_map_destroy (__mg_sys_bmp_map);
//delete all entries
RES_LOCK();
for(i=0; i<hash_table.size; i++){
@@ -487,6 +484,10 @@ void TerminateResManager()
user_types = NULL;
user_type_count = 0;
UNINIT_LOCKER();
/* Since 5.0.0, destroy the map for system bitmaps */
__mg_map_destroy (__mg_sys_bmp_map);
}
const char* __sysres_get_system_res_path()