mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
Refactor glib/glib-init.c to isolate init/deinit steps in isolated functions
This commit is contained in:
parent
4fdbfcc9b7
commit
2ff2c9eb5b
@ -342,12 +342,36 @@ glib_init (void)
|
||||
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
|
||||
HMODULE glib_dll = NULL;
|
||||
|
||||
static void
|
||||
glib_win32_init (void)
|
||||
{
|
||||
g_crash_handler_win32_init ();
|
||||
#ifdef THREADS_WIN32
|
||||
g_thread_win32_init ();
|
||||
#endif
|
||||
|
||||
g_clock_win32_init ();
|
||||
glib_init ();
|
||||
/* must go after glib_init */
|
||||
g_console_win32_init ();
|
||||
}
|
||||
|
||||
static void
|
||||
glib_win32_deinit (gboolean detach_thread)
|
||||
{
|
||||
#ifdef THREADS_WIN32
|
||||
if (detach_thread)
|
||||
g_thread_win32_process_detach ();
|
||||
#endif
|
||||
g_crash_handler_win32_deinit ();
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain (HINSTANCE hinstDLL,
|
||||
DWORD fdwReason,
|
||||
LPVOID lpvReserved);
|
||||
|
||||
HMODULE glib_dll;
|
||||
|
||||
BOOL WINAPI
|
||||
DllMain (HINSTANCE hinstDLL,
|
||||
DWORD fdwReason,
|
||||
@ -357,14 +381,7 @@ DllMain (HINSTANCE hinstDLL,
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
glib_dll = hinstDLL;
|
||||
g_crash_handler_win32_init ();
|
||||
g_clock_win32_init ();
|
||||
#ifdef THREADS_WIN32
|
||||
g_thread_win32_init ();
|
||||
#endif
|
||||
glib_init ();
|
||||
/* must go after glib_init */
|
||||
g_console_win32_init ();
|
||||
glib_win32_init ();
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
@ -374,11 +391,7 @@ DllMain (HINSTANCE hinstDLL,
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
#ifdef THREADS_WIN32
|
||||
if (lpvReserved == NULL)
|
||||
g_thread_win32_process_detach ();
|
||||
#endif
|
||||
g_crash_handler_win32_deinit ();
|
||||
glib_win32_deinit (lpvReserved == NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -389,7 +402,7 @@ DllMain (HINSTANCE hinstDLL,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#elif defined (G_HAS_CONSTRUCTORS)
|
||||
#elif defined(G_HAS_CONSTRUCTORS) /* && !G_PLATFORM_WIN32 */
|
||||
|
||||
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
|
||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(glib_init_ctor)
|
||||
@ -402,6 +415,6 @@ glib_init_ctor (void)
|
||||
glib_init ();
|
||||
}
|
||||
|
||||
#else
|
||||
#else /* !G_PLATFORM_WIN32 && !G_HAS_CONSTRUCTORS */
|
||||
# error Your platform/compiler is missing constructor support
|
||||
#endif
|
||||
#endif /* G_PLATFORM_WIN32 */
|
||||
|
Loading…
Reference in New Issue
Block a user