diff --git a/ChangeLog b/ChangeLog index 7d23a7eef..48857e6fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-08-31 Tor Lillqvist + + * glib/gutils.h: Wrapping atexit() is a bad idea on Windows, where + the EXE and each DLL have their own atexit function chains. + + #define g_atexit as atexit instead. This means it has a + better chance of doing what the caller wants. For instance, + gtkhtml calls g_atexit() registering a function in gtkhtml + itself. This caused a crash when g_atexit() was implemented as a + function in the GLib DLL. The gtkhtml DLL was already unloaded by + the time the GLib DLL got unloaded. + + * glib/gutils.c: #undef the #define mentioned above, to also get a + real g_atexit() into the DLL for backward compatibility. + 2005-08-30 Tor Lillqvist Make also the g_spawn*() functions take parameters in the GLib diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7d23a7eef..48857e6fd 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,18 @@ +2005-08-31 Tor Lillqvist + + * glib/gutils.h: Wrapping atexit() is a bad idea on Windows, where + the EXE and each DLL have their own atexit function chains. + + #define g_atexit as atexit instead. This means it has a + better chance of doing what the caller wants. For instance, + gtkhtml calls g_atexit() registering a function in gtkhtml + itself. This caused a crash when g_atexit() was implemented as a + function in the GLib DLL. The gtkhtml DLL was already unloaded by + the time the GLib DLL got unloaded. + + * glib/gutils.c: #undef the #define mentioned above, to also get a + real g_atexit() into the DLL for backward compatibility. + 2005-08-30 Tor Lillqvist Make also the g_spawn*() functions take parameters in the GLib diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 7d23a7eef..48857e6fd 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,18 @@ +2005-08-31 Tor Lillqvist + + * glib/gutils.h: Wrapping atexit() is a bad idea on Windows, where + the EXE and each DLL have their own atexit function chains. + + #define g_atexit as atexit instead. This means it has a + better chance of doing what the caller wants. For instance, + gtkhtml calls g_atexit() registering a function in gtkhtml + itself. This caused a crash when g_atexit() was implemented as a + function in the GLib DLL. The gtkhtml DLL was already unloaded by + the time the GLib DLL got unloaded. + + * glib/gutils.c: #undef the #define mentioned above, to also get a + real g_atexit() into the DLL for backward compatibility. + 2005-08-30 Tor Lillqvist Make also the g_spawn*() functions take parameters in the GLib diff --git a/glib/gutils.c b/glib/gutils.c index 8f7adc10b..69d6b4375 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -208,6 +208,10 @@ g_memmove (gpointer dest, } #endif /* !HAVE_MEMMOVE && !HAVE_WORKING_BCOPY */ +#ifdef G_OS_WIN32 +#undef g_atexit +#endif + /** * g_atexit: * @func: the function to call on normal program termination. diff --git a/glib/gutils.h b/glib/gutils.h index 3cb781f0b..5350b9c1d 100644 --- a/glib/gutils.h +++ b/glib/gutils.h @@ -229,6 +229,17 @@ typedef void (*GVoidFunc) (void); */ void g_atexit (GVoidFunc func); +#ifdef G_OS_WIN32 +/* It's a bad idea to wrap atexit() on Windows. If the GLib DLL calls + * atexit(), the function will be called when the GLib DLL is detached + * from the program, which is not what the caller wants. The caller + * wants the function to be called when it *itself* exits (or is + * detached, in case the caller, too, is a DLL). + */ +int atexit (void (*)(void)); +#define g_atexit(func) atexit(func) +#endif + /* Look for an executable in PATH, following execvp() rules */ gchar* g_find_program_in_path (const gchar *program);