Make the implementation of GPrivate behave more closely as in POSIX
authorTor Lillqvist <tml@novell.com>
Mon, 20 Feb 2006 02:47:30 +0000 (02:47 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Mon, 20 Feb 2006 02:47:30 +0000 (02:47 +0000)
2006-02-20  Tor Lillqvist  <tml@novell.com>

* gthread-win32.c (g_thread_exit_win32_impl): Make the
implementation of GPrivate behave more closely as in POSIX
threads: The value associacted with a GPrivate must be set to NULL
before calling the destructor. (The destructor gets the original
value as argument.)  A destructor might re-associate a non-NULL
value with some GPrivate. To deal with this, if after all
destructors have been called, there still are some non-NULL
values, the process is repeated. (#331367)

gthread/ChangeLog
gthread/gthread-win32.c

index 38b646d..b0a7d6d 100644 (file)
@@ -1,3 +1,14 @@
+2006-02-20  Tor Lillqvist  <tml@novell.com>
+
+       * gthread-win32.c (g_thread_exit_win32_impl): Make the
+       implementation of GPrivate behave more closely as in POSIX
+       threads: The value associacted with a GPrivate must be set to NULL
+       before calling the destructor. (The destructor gets the original
+       value as argument.)  A destructor might re-associate a non-NULL
+       value with some GPrivate. To deal with this, if after all
+       destructors have been called, there still are some non-NULL
+       values, the process is repeated. (#331367)
+
 2006-02-10  Matthias Clasen  <mclasen@redhat.com>
 
        * === Released 2.9.6 ===
index 358ba6e..e90bc60 100644 (file)
@@ -414,13 +414,24 @@ g_thread_exit_win32_impl (void)
 
   if (array)
     {
-      for (i = 0; i < private_max; i++)
-       {
-         GDestroyNotify destructor = g_private_destructors[i];
-         GDestroyNotify data = array[i];
-         if (destructor && data)
-           destructor (data);
-       }
+      gboolean some_data_non_null;
+
+      do {
+       some_data_non_null = FALSE;
+       for (i = 0; i < private_max; i++)
+         {
+           GDestroyNotify destructor = g_private_destructors[i];
+           GDestroyNotify data = array[i];
+           
+           if (data)
+             some_data_non_null = TRUE;
+
+           array[i] = NULL;
+           
+           if (destructor && data)
+             destructor (data);
+         }
+      } while (some_data_non_null);
 
       g_free (array);