#include "gcancellable.h"
#include "glibintl.h"
-#include "gioalias.h"
/**
* SECTION:gcancellable
*
* 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 *
{
GCancellablePrivate *priv;
+ if (cancellable == NULL)
+ return;
+
g_return_if_fail (G_IS_CANCELLABLE (cancellable));
g_return_if_fail (cancellable->priv->fd_refcount > 0);
void
g_cancellable_cancel (GCancellable *cancellable)
{
- gboolean cancel;
GCancellablePrivate *priv;
if (cancellable == NULL ||
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
}
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);
}
/**
g_signal_handler_disconnect (cancellable, handler_id);
G_UNLOCK (cancellable);
}
-
-#define __G_CANCELLABLE_C__
-#include "gioaliasdef.c"