Merge remote branch 'gvdb/master'
[platform/upstream/glib.git] / gio / gcancellable.c
index 07b61b7..3a99532 100644 (file)
@@ -34,7 +34,6 @@
 #include "gcancellable.h"
 #include "glibintl.h"
 
-#include "gioalias.h"
 
 /**
  * SECTION:gcancellable
@@ -334,7 +333,7 @@ g_cancellable_pop_current (GCancellable *cancellable)
  *
  * Gets the top cancellable from the stack.
  *
- * Returns: a #GCancellable from the top of the stack, or %NULL
+ * Returns: (transfer none): a #GCancellable from the top of the stack, or %NULL
  * if the stack is empty.
  **/
 GCancellable *
@@ -579,6 +578,9 @@ g_cancellable_release_fd (GCancellable *cancellable)
 {
   GCancellablePrivate *priv;
 
+  if (cancellable == NULL)
+    return;
+
   g_return_if_fail (G_IS_CANCELLABLE (cancellable));
   g_return_if_fail (cancellable->priv->fd_refcount > 0);
 
@@ -613,7 +615,6 @@ g_cancellable_release_fd (GCancellable *cancellable)
 void
 g_cancellable_cancel (GCancellable *cancellable)
 {
-  gboolean cancel;
   GCancellablePrivate *priv;
 
   if (cancellable == NULL ||
@@ -621,10 +622,14 @@ g_cancellable_cancel (GCancellable *cancellable)
     return;
 
   priv = cancellable->priv;
-  cancel = FALSE;
 
   G_LOCK(cancellable);
-  cancel = TRUE;
+  if (priv->cancelled)
+    {
+      G_UNLOCK (cancellable);
+      return;
+    }
+
   priv->cancelled = TRUE;
   priv->cancelled_running = TRUE;
 #ifdef G_OS_WIN32
@@ -642,22 +647,19 @@ g_cancellable_cancel (GCancellable *cancellable)
     }
   G_UNLOCK(cancellable);
 
-  if (cancel)
-    {
-      g_object_ref (cancellable);
-      g_signal_emit (cancellable, signals[CANCELLED], 0);
+  g_object_ref (cancellable);
+  g_signal_emit (cancellable, signals[CANCELLED], 0);
 
-      G_LOCK(cancellable);
+  G_LOCK(cancellable);
 
-      priv->cancelled_running = FALSE;
-      if (priv->cancelled_running_waiting)
-       g_cond_broadcast (cancellable_cond);
-      priv->cancelled_running_waiting = FALSE;
+  priv->cancelled_running = FALSE;
+  if (priv->cancelled_running_waiting)
+    g_cond_broadcast (cancellable_cond);
+  priv->cancelled_running_waiting = FALSE;
 
-      G_UNLOCK(cancellable);
+  G_UNLOCK(cancellable);
 
-      g_object_unref (cancellable);
-    }
+  g_object_unref (cancellable);
 }
 
 /**
@@ -768,6 +770,3 @@ g_cancellable_disconnect (GCancellable  *cancellable,
   g_signal_handler_disconnect (cancellable, handler_id);
   G_UNLOCK (cancellable);
 }
-
-#define __G_CANCELLABLE_C__
-#include "gioaliasdef.c"