コード例 #1
0
ファイル: gbinding.c プロジェクト: justinc1985/IntelRangeley
/* the basic assumption is that if either the source or the target
 * goes away then the binding does not exist any more and it should
 * be reaped as well
 */
static void
weak_unbind (gpointer  user_data,
             GObject  *where_the_object_was)
{
  GBinding *binding = user_data;

  /* if what went away was the source, unset it so that GBinding::finalize
   * does not try to access it; otherwise, disconnect everything and remove
   * the GBinding instance from the object's qdata
   */
  if (binding->source == where_the_object_was)
    binding->source = NULL;
  else
    {
      if (binding->source_notify != 0)
        g_signal_handler_disconnect (binding->source, binding->source_notify);

      g_object_weak_unref (binding->source, weak_unbind, user_data);
      remove_binding_qdata (binding->source, binding);

      binding->source_notify = 0;
      binding->source = NULL;
    }

  /* as above, but with the target */
  if (binding->target == where_the_object_was)
    binding->target = NULL;
  else
    {
      if (binding->target_notify != 0)
        g_signal_handler_disconnect (binding->target, binding->target_notify);

      g_object_weak_unref (binding->target, weak_unbind, user_data);
      remove_binding_qdata (binding->target, binding);

      binding->target_notify = 0;
      binding->target = NULL;
    }

  /* this will take care of the binding itself */
  g_object_unref (binding);
}
コード例 #2
0
ファイル: gbinding.c プロジェクト: justinc1985/IntelRangeley
static inline void
g_binding_unbind_internal (GBinding *binding,
                           gboolean  unref_binding)
{
  /* dispose of the transformation data */
  if (binding->notify != NULL)
    {
      binding->notify (binding->transform_data);

      binding->transform_data = NULL;
      binding->notify = NULL;
    }

  if (binding->source != NULL)
    {
      if (binding->source_notify != 0)
        g_signal_handler_disconnect (binding->source, binding->source_notify);

      g_object_weak_unref (binding->source, weak_unbind, binding);
      remove_binding_qdata (binding->source, binding);

      binding->source_notify = 0;
      binding->source = NULL;
    }

  if (binding->target != NULL)
    {
      if (binding->target_notify != 0)
        g_signal_handler_disconnect (binding->target, binding->target_notify);

      g_object_weak_unref (binding->target, weak_unbind, binding);
      remove_binding_qdata (binding->target, binding);

      binding->target_notify = 0;
      binding->target = NULL;
    }

  if (unref_binding)
    g_object_unref (binding);
}
コード例 #3
0
ファイル: gbinding.c プロジェクト: antono/glib
static void
g_binding_finalize (GObject *gobject)
{
  GBinding *binding = G_BINDING (gobject);

  /* dispose of the transformation data */
  if (binding->notify != NULL)
    {
      binding->notify (binding->transform_data);

      binding->transform_data = NULL;
      binding->notify = NULL;
    }

  /* we need this in case the source and target instance are still
   * valid, and it was the GBinding that was unreferenced
   */
  if (binding->source != NULL)
    {
      if (binding->source_notify != 0)
        g_signal_handler_disconnect (binding->source, binding->source_notify);

      g_object_weak_unref (binding->source, weak_unbind, binding);
      remove_binding_qdata (binding->source, binding);
    }

  if (binding->target != NULL)
    {
      if (binding->target_notify != 0)
        g_signal_handler_disconnect (binding->target, binding->target_notify);

      g_object_weak_unref (binding->target, weak_unbind, binding);
      remove_binding_qdata (binding->target, binding);
    }

  G_OBJECT_CLASS (g_binding_parent_class)->finalize (gobject);
}