A regression is still apparent in the GConf peer even with
a patch from Mario, so this patch simply regresses to the 0.96
version for the release.  I'll leave Mario to revert this and
fix the problem post-release.

ChangeLog:

2008-02-21  Andrew John Hughes  <[EMAIL PROTECTED]>

        * gnu/java/util/prefs/EventDispatcher.java:
        Re-added.
        * gnu/java/util/prefs/GConfBasedPreferences.java,
        * gnu/java/util/prefs/gconf/GConfNativePeer.java,
        * java/util/prefs/AbstractPreferences.java,
        * native/jni/gconf-peer/GConfNativePeer.c:
        Regress to 0.96 versions.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
Index: gnu/java/util/prefs/EventDispatcher.java
===================================================================
RCS file: gnu/java/util/prefs/EventDispatcher.java
diff -N gnu/java/util/prefs/EventDispatcher.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/util/prefs/EventDispatcher.java	22 Feb 2008 02:12:24 -0000
@@ -0,0 +1,113 @@
+/* EventDispatcher.java -- Dispatch events for prefs
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.util.prefs;
+
+import java.util.ArrayList;
+
+/**
+ * This is a helper class used for dispatching events for
+ * the prefs package.
+ */
+public class EventDispatcher extends Thread
+{
+  // This is a singleton class.  We dispatch all events via a
+  // new Thread which is created on demand.
+  private static final Thread dispatchThread = new EventDispatcher();
+
+  // This is a queue of events to dispatch.  This thread waits on
+  // the queue and when notified will remove events until the queue
+  // is empty.
+  private static final ArrayList<Runnable> queue = new ArrayList<Runnable>();
+
+  // FIXME: this thread probably ought to go in some classpath-internal
+  // ThreadGroup.  But we don't have that yet.
+  private EventDispatcher()
+  {
+    setDaemon(true);
+    start();
+  }
+
+  public void run()
+  {
+    while (true)
+      {
+        Runnable r;
+        synchronized (queue)
+          {
+            while (queue.size() == 0)
+              {
+                try
+                  {
+                    queue.wait();
+                  }
+                catch (InterruptedException _)
+                  {
+                    // Ignore.
+                  }
+              }
+            r = queue.remove(0);
+          }
+        // Invoke outside the synchronization, so that 
+        // we aren't blocking other threads from posting events.
+        try
+          {
+            r.run();
+          }
+        catch (Throwable _)
+          {
+            // Ignore.
+          }
+      }
+  }
+
+  /**
+   * Add a new runnable to the event dispatch queue.  The
+   * runnable will be invoked in the event dispatch queue
+   * without any locks held.
+   * @param runner the Runnable to dispatch
+   */
+  public static void dispatch(Runnable runner)
+  {
+    synchronized (queue)
+      {
+        queue.add(runner);
+	queue.notify();
+      }
+  }
+}
Index: gnu/java/util/prefs/GConfBasedPreferences.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/util/prefs/GConfBasedPreferences.java,v
retrieving revision 1.5
diff -u -3 -p -u -r1.5 GConfBasedPreferences.java
--- gnu/java/util/prefs/GConfBasedPreferences.java	23 Nov 2007 22:02:16 -0000	1.5
+++ gnu/java/util/prefs/GConfBasedPreferences.java	22 Feb 2008 02:12:25 -0000
@@ -166,6 +166,10 @@ public class GConfBasedPreferences
     GConfBasedPreferences preferenceNode
       = new GConfBasedPreferences(this, name, this.isUser);
     
+    // register the node for to GConf so that it can listen
+    // events outside the scope of the application
+    backend.startWatchingNode(this.node);
+    
     return preferenceNode;
   }
 
Index: gnu/java/util/prefs/gconf/GConfNativePeer.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/util/prefs/gconf/GConfNativePeer.java,v
retrieving revision 1.5
diff -u -3 -p -u -r1.5 GConfNativePeer.java
--- gnu/java/util/prefs/gconf/GConfNativePeer.java	23 Nov 2007 22:02:15 -0000	1.5
+++ gnu/java/util/prefs/gconf/GConfNativePeer.java	22 Feb 2008 02:12:25 -0000
@@ -49,11 +49,19 @@ import java.util.prefs.BackingStoreExcep
 public final class GConfNativePeer
 {
   /**
+   * Object to achieve locks for methods that need to be synchronized.
+   */
+  private static final Object[] semaphore = new Object[0];
+
+  /**
    * Creates a new instance of GConfNativePeer
    */
   public GConfNativePeer()
   {
-    init_class();
+    synchronized (semaphore)
+      {
+        init_class();
+      }
   }
 
   /**
@@ -64,7 +72,31 @@ public final class GConfNativePeer
    */
   public boolean nodeExist(String node)
   {
-    return gconf_dir_exists(node);
+    return gconf_client_dir_exists(node);
+  }
+
+  /**
+   * Add the node <code>node</code> to the list of nodes the GConf will watch.
+   * An event is raised everytime this node is changed. You can add a node
+   * multiple times.
+   * 
+   * @param node the node to track.
+   */
+  public void startWatchingNode(String node)
+  {
+    gconf_client_add_dir(node);
+  }
+
+  /**
+   * Remove the node <code>node</code> to the list of nodes the GConf is
+   * watching. Note that if a node has been added multiple times, you must
+   * remove it the same number of times before the remove takes effect.
+   * 
+   * @param node the node you don't want to track anymore.
+   */
+  public void stopWatchingNode(String node)
+  {
+    gconf_client_remove_dir(node);
   }
 
   /**
@@ -79,7 +111,7 @@ public final class GConfNativePeer
    */
   public boolean setString(String key, String value)
   {
-    return gconf_set_string(key, value);
+    return gconf_client_set_string(key, value);
   }
 
   /**
@@ -92,7 +124,7 @@ public final class GConfNativePeer
    */
   public boolean unset(String key)
   {
-    return gconf_unset(key);
+    return gconf_client_unset(key);
   }
 
   /**
@@ -103,7 +135,7 @@ public final class GConfNativePeer
    */
   public String getKey(String key)
   {
-    return gconf_get_string(key);
+    return gconf_client_get_string(key);
   }
 
   /**
@@ -117,7 +149,7 @@ public final class GConfNativePeer
    */
   public List<String> getKeys(String node) throws BackingStoreException
   {
-    return gconf_all_keys(node);
+    return gconf_client_all_keys(node);
   }
 
   /**
@@ -129,7 +161,7 @@ public final class GConfNativePeer
    */
   public List<String> getChildrenNodes(String node) throws BackingStoreException
   {
-    return gconf_all_nodes(node);
+    return gconf_client_all_nodes(node);
   }
 
   /**
@@ -153,14 +185,17 @@ public final class GConfNativePeer
    */
   public void suggestSync() throws BackingStoreException
   {
-    gconf_suggest_sync();
+    gconf_client_suggest_sync();
   }
   
   protected void finalize() throws Throwable
   {
     try
       {
-        finalize_class();
+        synchronized (semaphore)
+          {
+            finalize_class();
+          }
       }
     finally
       {
@@ -180,18 +215,18 @@ public final class GConfNativePeer
    * Initialize the GConf native peer and enable the object cache.
    * It is meant to be used by the static initializer.
    */
-  native synchronized static final private void init_id_cache();
+  native static final private void init_id_cache();
   
   /**
    * Initialize the GConf native peer. This is meant to be used by the
    * class constructor.
    */
-  native synchronized static final private void init_class();
+  native static final private void init_class();
 
   /**
    * Class finalizer.
    */
-  native synchronized static final private void finalize_class();
+  native static final private void finalize_class();
 
   /**
    * Queries the GConf database to see if the given node exists, returning
@@ -200,8 +235,23 @@ public final class GConfNativePeer
    * @param node the node to query for existence.
    * @return true if the node exist, false otherwise.
    */
-  native synchronized
-  static final protected boolean gconf_dir_exists(String node);
+  native static final protected boolean gconf_client_dir_exists(String node);
+
+  /**
+   * Adds the given node to the list of nodes that GConf watches for
+   * changes.
+   * 
+   * @param node the node to watch for changes.
+   */
+  native static final protected void gconf_client_add_dir(String node);
+
+  /**
+   * Removes the given node from the list of nodes that GConf watches for
+   * changes.
+   * 
+   * @param node the node to remove from from the list of watched nodes.
+   */
+  native static final protected void gconf_client_remove_dir(String node);
 
   /**
    * Sets the given key/value pair into the GConf database.
@@ -211,8 +261,8 @@ public final class GConfNativePeer
    * @param value the value to associate to the given key.
    * @return true if the change has effect, false otherwise.
    */
-  native synchronized
-  static final protected boolean gconf_set_string(String key, String value);
+  native static final protected boolean gconf_client_set_string(String key,
+                                                                String value);
 
   /**
    * Returns the key associated to the given key. Null is returned if the
@@ -221,8 +271,7 @@ public final class GConfNativePeer
    * @param key the key to return the value of.
    * @return The value associated to the given key, or null.
    */
-  native synchronized
-  static final protected String gconf_get_string(String key);
+  native static final protected String gconf_client_get_string(String key);
 
   /**
    * Usets the given key, removing the key from the database.
@@ -230,13 +279,13 @@ public final class GConfNativePeer
    * @param key the key to remove.
    * @return true if the operation success, false otherwise.
    */
-  native synchronized static final protected boolean gconf_unset(String key);
+  native static final protected boolean gconf_client_unset(String key);
 
   /**
    * Suggest to the GConf native peer a sync with the database.
    *
    */
-  native synchronized static final protected void gconf_suggest_sync()
+  native static final protected void gconf_client_suggest_sync()
     throws BackingStoreException;
   
   /**
@@ -246,7 +295,7 @@ public final class GConfNativePeer
    * @return A list of nodes under the given source node.
    */
   native
-  static synchronized final protected List<String> gconf_all_nodes(String node)
+  static final protected List<String> gconf_client_all_nodes(String node)
     throws BackingStoreException;
   
   /**
@@ -255,8 +304,8 @@ public final class GConfNativePeer
    * @param node the source node.
    * @return A list of all keys stored in the given node.
    */
-  native synchronized 
-  static final protected List<String> gconf_all_keys(String node)
+  native
+  static final protected List<String> gconf_client_all_keys(String node)
     throws BackingStoreException;
 
   /**
@@ -265,7 +314,7 @@ public final class GConfNativePeer
    * @param plain the String to escape.
    * @return An escaped String for use with GConf.
    */
-  native synchronized 
+  native
   static final protected String gconf_escape_key(String plain);
   
   /**
@@ -275,7 +324,7 @@ public final class GConfNativePeer
    * @param escaped key as returned by gconf_escape_key 
    * @return An unescaped key.
    */
-  native synchronized 
+  native
   static final protected String gconf_unescape_key(String escaped);
   
   static
Index: java/util/prefs/AbstractPreferences.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/prefs/AbstractPreferences.java,v
retrieving revision 1.16
diff -u -3 -p -u -r1.16 AbstractPreferences.java
--- java/util/prefs/AbstractPreferences.java	23 Nov 2007 22:02:15 -0000	1.16
+++ java/util/prefs/AbstractPreferences.java	22 Feb 2008 02:12:25 -0000
@@ -38,7 +38,7 @@ exception statement from your version. *
 
 package java.util.prefs;
 
-import gnu.classpath.toolkit.DefaultDaemonThreadFactory;
+import gnu.java.util.prefs.EventDispatcher;
 import gnu.java.util.prefs.NodeWriter;
 
 import java.io.ByteArrayOutputStream;
@@ -49,8 +49,6 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.TreeSet;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
 
 /**
  * Partial implementation of a Preference node.
@@ -1238,18 +1236,17 @@ public abstract class AbstractPreference
      */
     private void fire(final PreferenceChangeEvent event)
     {
-      for (final PreferenceChangeListener listener : preferenceListeners)
+      Iterator it = preferenceListeners.iterator();
+      while (it.hasNext())
         {
-          Runnable dispatcher = new Runnable() {
-            public void run()
-            {
-              listener.preferenceChange(event);
-            }
-          };
-          
-          Executor executor =
-            Executors.newSingleThreadExecutor(new DefaultDaemonThreadFactory());
-          executor.execute(dispatcher);
+          final PreferenceChangeListener l = (PreferenceChangeListener) it.next();
+          EventDispatcher.dispatch(new Runnable()
+                                   {
+                                     public void run()
+                                     {
+                                       l.preferenceChange(event);
+                                     }
+                                   });
         }
     }
 
@@ -1261,21 +1258,20 @@ public abstract class AbstractPreference
      */
     private void fire(final NodeChangeEvent event, final boolean added)
     {
-      for (final NodeChangeListener listener : nodeListeners)
+      Iterator it = nodeListeners.iterator();
+      while (it.hasNext())
         {
-          Runnable dispatcher = new Runnable() {
-            public void run()
-            {
-              if (added)
-                listener.childAdded(event);
-              else
-                listener.childRemoved(event);
-            }
-          };
-          
-          Executor executor =
-            Executors.newSingleThreadExecutor(new DefaultDaemonThreadFactory());
-          executor.execute(dispatcher);
+          final NodeChangeListener l = (NodeChangeListener) it.next();
+          EventDispatcher.dispatch(new Runnable()
+                                   {
+                                     public void run()
+                                     {
+                                       if (added)
+                                         l.childAdded(event);
+                                       else
+                                         l.childRemoved(event);
+                                     }
+                                   });
         }
     }
 
Index: native/jni/gconf-peer/GConfNativePeer.c
===================================================================
RCS file: /sources/classpath/classpath/native/jni/gconf-peer/GConfNativePeer.c,v
retrieving revision 1.11
diff -u -3 -p -u -r1.11 GConfNativePeer.c
--- native/jni/gconf-peer/GConfNativePeer.c	9 Feb 2008 18:57:21 -0000	1.11
+++ native/jni/gconf-peer/GConfNativePeer.c	22 Feb 2008 02:12:26 -0000
@@ -70,10 +70,12 @@ static jmethodID jlist_add_id = NULL;
 /* ***** PRIVATE FUNCTIONS DELCARATION ***** */
 
 /**
- * Gets the reference of the default GConfClient..
+ * Gets the reference of the default GConfClient and initialize the
+ * the type system.
  * The client reference should be released with g_object_unref after use.
+ * This functions must be called with gdk lock held.
  */
-static void init_gconf (void);
+static void init_gconf_client (void);
 
 /**
  * Throws a new runtime exception after a failure, with the given message.
@@ -131,7 +133,9 @@ Java_gnu_java_util_prefs_gconf_GConfNati
 {
   reference_count++;
 
-  init_gconf ();
+  gdk_threads_enter ();
+  init_gconf_client ();
+  gdk_threads_leave ();
 
   /* if client is null, there is probably an out of memory */
   if (client == NULL)
@@ -153,11 +157,11 @@ Java_gnu_java_util_prefs_gconf_GConfNati
 
 /*
  * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
- * Method:    gconf_all_keys
+ * Method:    gconf_client_all_keys
  * Signature: (Ljava/lang/String;)Ljava/util/List;
  */
 JNIEXPORT jobject JNICALL
-Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1keys
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1keys
   (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
 {
   /* TODO: check all the calls to gdk_threads_enter/leave */
@@ -179,7 +183,9 @@ Java_gnu_java_util_prefs_gconf_GConfNati
       return NULL;
     }
 
+  gdk_threads_enter ();
   entries = gconf_client_all_entries (client, dir, &err);
+  gdk_threads_leave ();
   if (err != NULL)
     {
       throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
@@ -229,11 +235,11 @@ Java_gnu_java_util_prefs_gconf_GConfNati
 
 /*
  * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
- * Method:    gconf_all_nodes
+ * Method:    gconf_client_all_nodes
  * Signature: (Ljava/lang/String;)Ljava/util/List;
  */
 JNIEXPORT jobject JNICALL
-Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1nodes
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1nodes
   (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
 {
   const char *dir = NULL;
@@ -253,7 +259,9 @@ Java_gnu_java_util_prefs_gconf_GConfNati
       return NULL;
     }
 
+  gdk_threads_enter ();
   entries = gconf_client_all_dirs (client, dir, &err);
+  gdk_threads_leave ();
   if (err != NULL)
     {
       throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
@@ -303,16 +311,18 @@ Java_gnu_java_util_prefs_gconf_GConfNati
 
 /*
  * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
- * Method:    gconf_suggest_sync
+ * Method:    gconf_client_suggest_sync
  * Signature: ()V
  */
 JNIEXPORT void JNICALL
-Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1suggest_1sync
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1suggest_1sync
   (JNIEnv *env, jclass clazz __attribute__ ((unused)))
 {
   GError *err = NULL;
 
+  gdk_threads_enter ();
   gconf_client_suggest_sync (client, &err);
+  gdk_threads_leave ();
   if (err != NULL)
     {
       throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
@@ -324,11 +334,11 @@ Java_gnu_java_util_prefs_gconf_GConfNati
 
 /*
  * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
- * Method:    gconf_unset
+ * Method:    gconf_client_unset
  * Signature: (Ljava/lang/String;)Z
  */
 JNIEXPORT jboolean JNICALL
-Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unset
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1unset
   (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key)
 {
   const char *_key = NULL;
@@ -341,7 +351,9 @@ Java_gnu_java_util_prefs_gconf_GConfNati
       return JNI_FALSE;
     }
 
+  gdk_threads_enter ();
   result = gconf_client_unset (client, _key, &err);
+  gdk_threads_leave ();
   if (err != NULL)
     {
       result = JNI_FALSE;
@@ -356,11 +368,11 @@ Java_gnu_java_util_prefs_gconf_GConfNati
 
 /*
  * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
- * Method:    gconf_get_string
+ * Method:    gconf_client_get_string
  * Signature: (Ljava/lang/String;)Ljava/lang/String;
  */
 JNIEXPORT jstring JNICALL
-Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1get_1string
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string
   (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key)
 {
   const char *_key = NULL;
@@ -374,7 +386,9 @@ Java_gnu_java_util_prefs_gconf_GConfNati
       return NULL;
     }
 
+  gdk_threads_enter ();
   _value = gconf_client_get_string (client, _key, &err);
+  gdk_threads_leave ();
   JCL_free_cstring (env, key, _key);
   if (err != NULL)
     {
@@ -393,19 +407,17 @@ Java_gnu_java_util_prefs_gconf_GConfNati
       result = (*env)->NewStringUTF (env, _value);
       g_free ((gpointer) _value);
     }
-  
-  gconf_client_suggest_sync (client, NULL);
-  
+
   return result;
 }
 
 /*
  * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
- * Method:    gconf_set_string
+ * Method:    gconf_client_set_string
  * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
  */
 JNIEXPORT jboolean JNICALL
-Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1set_1string
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string
   (JNIEnv *env, jclass clazz __attribute__ ((unused)),
    jstring key, jstring value)
 {
@@ -423,7 +435,9 @@ Java_gnu_java_util_prefs_gconf_GConfNati
       return JNI_FALSE;
     }
 
+  gdk_threads_enter ();
   result = gconf_client_set_string (client, _key, _value, &err);
+  gdk_threads_leave ();
   if (err != NULL)
   	{
       g_error_free (err);
@@ -439,11 +453,56 @@ Java_gnu_java_util_prefs_gconf_GConfNati
 
 /*
  * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
- * Method:    gconf_dir_exists
+ * Method:    gconf_client_remove_dir
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1remove_1dir
+  (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
+{
+  const char *dir = NULL;
+
+  dir = JCL_jstring_to_cstring (env, node);
+  if (dir == NULL)
+    return;
+
+  gdk_threads_enter ();
+  gconf_client_remove_dir (client, dir, NULL);
+  gdk_threads_leave ();
+
+  JCL_free_cstring (env, node, dir);
+}
+
+/*
+ * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method:    gconf_client_add_dir
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir
+  (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
+{
+  const char *dir = NULL;
+
+  dir = JCL_jstring_to_cstring (env, node);
+  if (dir == NULL)
+    return;
+
+  /* ignore errors */
+  gdk_threads_enter ();
+  gconf_client_add_dir (client, dir, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+  gdk_threads_leave ();
+
+  JCL_free_cstring (env, node, dir);
+}
+
+/*
+ * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method:    gconf_client_dir_exists
  * Signature: (Ljava/lang/String;)Z
  */
 JNIEXPORT jboolean JNICALL
-Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1dir_1exists
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists
   (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
 {
   const char *dir = NULL;
@@ -455,7 +514,9 @@ Java_gnu_java_util_prefs_gconf_GConfNati
     return value;
 
   /* on error return false */
+  gdk_threads_enter ();
   value = gconf_client_dir_exists (client, dir, &err);
+  gdk_threads_leave ();
   if (err != NULL)
     value = JNI_FALSE;
 
@@ -476,8 +537,10 @@ Java_gnu_java_util_prefs_gconf_GConfNati
   if (reference_count == 0)
     {
       /* last reference, free all resources and return */
+      gdk_threads_enter ();
       g_object_unref (G_OBJECT (client));
-      
+      gdk_threads_leave ();
+
       (*env)->DeleteGlobalRef (env, jlist_class);
 
       jlist_class = NULL;
@@ -509,7 +572,9 @@ Java_gnu_java_util_prefs_gconf_GConfNati
       return NULL;
     }
 
+  gdk_threads_enter ();
   escaped = gconf_escape_key (_plain, strlen (_plain));
+  gdk_threads_leave ();
   
   JCL_free_cstring (env, plain, _plain);
   /* check for NULL, if so prevent string creation */
@@ -541,7 +606,9 @@ Java_gnu_java_util_prefs_gconf_GConfNati
       return NULL;
     }
 
+  gdk_threads_enter ();
   plain = gconf_unescape_key (_escaped, strlen (_escaped));
+  gdk_threads_leave ();
   
   JCL_free_cstring (env, escaped, _escaped);
   /* check for NULL, if so prevent string creation */
@@ -569,8 +636,9 @@ throw_exception_by_name (JNIEnv *env, co
   JCL_ThrowException (env, name, msg);
 }
 
-static void init_gconf (void)
+static void init_gconf_client (void)
 {
+  g_type_init ();
   client = gconf_client_get_default ();
 }
 

Attachment: signature.asc
Description: Digital signature

Reply via email to