示例#1
0
static GstGLContext *
_get_gl_context_for_thread_unlocked (GstGLDisplay * display, GThread * thread)
{
  GstGLContext *context = NULL;
  GList *prev = NULL, *l = display->priv->contexts;

  while (l) {
    GWeakRef *ref = l->data;
    GThread *context_thread;

    context = g_weak_ref_get (ref);
    if (!context) {
      /* remove dead contexts */
      g_weak_ref_clear (l->data);
      display->priv->contexts = g_list_delete_link (display->priv->contexts, l);
      l = prev ? prev->next : display->priv->contexts;
      continue;
    }

    context_thread = gst_gl_context_get_thread (context);
    if (thread != NULL && thread == context_thread) {
      g_thread_unref (context_thread);
      gst_object_unref (context);
      prev = l;
      l = l->next;
      continue;
    }

    if (context_thread)
      g_thread_unref (context_thread);
    return context;
  }

  return NULL;
}
示例#2
0
void
utils_free_weak_ref(GWeakRef* ref)
{
    g_weak_ref_clear(ref);

    g_clear_pointer(&ref, g_free);
}
示例#3
0
文件: util.c 项目: vifino/dwb
void 
util_free_weak_ref(GWeakRef *ref) {
    g_return_if_fail(ref != NULL);

    g_weak_ref_clear(ref);
    g_free(ref);
}
示例#4
0
文件: gda-pstmt.c 项目: GNOME/libgda
static void
gda_pstmt_dispose (GObject *object)
{
	GdaPStmt *pstmt = (GdaPStmt *) object;
	GdaPStmtPrivate *priv = gda_pstmt_get_instance_private (pstmt);

	gda_stmt_reset_cb (NULL, pstmt);

	/* free memory */
	g_rec_mutex_clear (& priv->mutex);
	g_weak_ref_clear (&priv->gda_stmt_ref);

	if (priv->sql != NULL) {
		g_free (priv->sql);
		priv->sql = NULL;
	}
	if (priv->param_ids != NULL) {
		g_slist_free_full (priv->param_ids, (GDestroyNotify) g_free);
		priv->param_ids = NULL;
	}
	if (priv->types != NULL) {
		g_free (priv->types);
		priv->types = NULL;
	}
	if (priv->tmpl_columns != NULL) {
		g_slist_free_full (priv->tmpl_columns, (GDestroyNotify) g_object_unref);
		priv->tmpl_columns = NULL;
	}

	/* chain to parent class */
	G_OBJECT_CLASS (gda_pstmt_parent_class)->dispose (object);
}
示例#5
0
static void
gst_gl_window_finalize (GObject * object)
{
  GstGLWindow *window = GST_GL_WINDOW (object);
  GstGLWindowPrivate *priv = window->priv;

  GST_INFO ("quit navigation loop");
  if (window->priv->navigation_loop) {
    g_main_loop_quit (window->priv->navigation_loop);
    /* wait until navigation thread finished */
    g_thread_join (window->priv->navigation_thread);
    window->priv->navigation_thread = NULL;
  }

  if (priv->loop)
    g_main_loop_unref (priv->loop);

  if (priv->main_context)
    g_main_context_unref (priv->main_context);

  g_weak_ref_clear (&window->context_ref);

  g_mutex_clear (&window->lock);
  g_mutex_clear (&window->priv->nav_lock);
  g_cond_clear (&window->priv->nav_create_cond);
  g_mutex_clear (&window->priv->sync_message_lock);
  g_cond_clear (&window->priv->sync_message_cond);
  gst_object_unref (window->display);

  G_OBJECT_CLASS (gst_gl_window_parent_class)->finalize (object);
}
示例#6
0
static void
gda_pstmt_finalize (GObject *object)
{
	GdaPStmt *pstmt = (GdaPStmt *) object;

	/* free memory */
	g_weak_ref_clear (& pstmt->priv->gda_stmt_ref);
	g_rec_mutex_clear (& pstmt->priv->mutex);
	g_free (pstmt->priv);

	if (pstmt->sql) {
		g_free (pstmt->sql);
		pstmt->sql = NULL;
	}
	if (pstmt->param_ids) {
		g_slist_foreach (pstmt->param_ids, (GFunc) g_free, NULL);
		g_slist_free (pstmt->param_ids);
		pstmt->param_ids = NULL;
	}
	if (pstmt->types) {
		g_free (pstmt->types);
		pstmt->types = NULL;
	}
	if (pstmt->tmpl_columns) {
		g_slist_foreach (pstmt->tmpl_columns, (GFunc) g_object_unref, NULL);
		g_slist_free (pstmt->tmpl_columns);
	}

	/* chain to parent class */
	parent_class->finalize (object);
}
示例#7
0
static void
dconf_settings_backend_free_weak_ref (gpointer data)
{
  GWeakRef *weak_ref = data;

  g_weak_ref_clear (weak_ref);
  g_slice_free (GWeakRef, weak_ref);
}
static void
gst_validate_monitor_dispose (GObject * object)
{
  GstValidateMonitor *monitor = GST_VALIDATE_MONITOR_CAST (object);

  g_mutex_clear (&monitor->mutex);
  g_mutex_clear (&monitor->overrides_mutex);
  g_queue_clear (&monitor->overrides);

  g_weak_ref_clear (&monitor->pipeline);
  g_weak_ref_clear (&monitor->target);

  if (monitor->media_descriptor)
    gst_object_unref (monitor->media_descriptor);

  G_OBJECT_CLASS (parent_class)->dispose (object);
}
示例#9
0
static void
gda_web_pstmt_finalize (GObject *object)
{
	GdaWebPStmt *pstmt = (GdaWebPStmt *) object;

	g_return_if_fail (GDA_IS_PSTMT (pstmt));
  GdaWebPStmtPrivate *priv = gda_web_pstmt_get_instance_private (pstmt);
  g_weak_ref_clear (&priv->cnc);
}
static void
yahoo_backend_finalize (GObject *object)
{
	EYahooBackend *backend = E_YAHOO_BACKEND (object);

	g_weak_ref_clear (&backend->mail_identity_source);

	G_OBJECT_CLASS (e_yahoo_backend_parent_class)->finalize (object);
}
示例#11
0
static void
component_source_finalize (GSource *source)
{
  ComponentSource *component_source = (ComponentSource *) source;

  g_slist_free_full (component_source->socket_sources, free_child_socket_source);

  g_weak_ref_clear (&component_source->agent_ref);
  g_object_unref (component_source->pollable_stream);
  component_source->pollable_stream = NULL;
}
示例#12
0
static void
gst_gl_window_finalize (GObject * object)
{
  GstGLWindow *window = GST_GL_WINDOW (object);

  g_weak_ref_clear (&window->context_ref);

  g_mutex_clear (&window->lock);
  gst_object_unref (window->display);

  G_OBJECT_CLASS (gst_gl_window_parent_class)->finalize (object);
}
void
gtk_gst_base_widget_finalize (GObject * object)
{
  GtkGstBaseWidget *widget = GTK_GST_BASE_WIDGET (object);

  gst_buffer_replace (&widget->pending_buffer, NULL);
  gst_buffer_replace (&widget->buffer, NULL);
  g_mutex_clear (&widget->lock);
  g_weak_ref_clear (&widget->element);

  if (widget->draw_id)
    g_source_remove (widget->draw_id);
}
示例#14
0
文件: tools.c 项目: Buzztrax/buzztrax
static gboolean
on_idle_notify (gpointer user_data)
{
  BtNotifyIdleData *data = (BtNotifyIdleData *) user_data;
  gpointer weak_data = g_weak_ref_get (&data->user_data);

  if (weak_data) {
    data->func (data->object, data->pspec, weak_data);
    g_object_unref (weak_data);
  }
  g_weak_ref_clear (&data->user_data);
  g_slice_free (BtNotifyIdleData, data);
  return FALSE;
}
示例#15
0
static void
gst_gl_context_finalize (GObject * object)
{
  GstGLContext *context = GST_GL_CONTEXT (object);

  if (context->window) {
    gst_gl_window_set_resize_callback (context->window, NULL, NULL, NULL);
    gst_gl_window_set_draw_callback (context->window, NULL, NULL, NULL);

    if (context->priv->alive) {
      g_mutex_lock (&context->priv->render_lock);
      GST_INFO_OBJECT (context, "send quit gl window loop");
      gst_gl_window_quit (context->window);
      while (context->priv->alive) {
        g_cond_wait (&context->priv->destroy_cond, &context->priv->render_lock);
      }
      g_mutex_unlock (&context->priv->render_lock);
    }

    gst_gl_window_set_close_callback (context->window, NULL, NULL, NULL);

    if (context->priv->gl_thread) {
      gpointer ret = g_thread_join (context->priv->gl_thread);
      GST_INFO_OBJECT (context, "gl thread joined");
      if (ret != NULL)
        GST_ERROR_OBJECT (context, "gl thread returned a non-null pointer");
      context->priv->gl_thread = NULL;
    }

    gst_object_unref (context->window);
  }

  gst_object_unref (context->display);

  if (context->gl_vtable) {
    g_slice_free (GstGLFuncs, context->gl_vtable);
    context->gl_vtable = NULL;
  }

  g_mutex_clear (&context->priv->render_lock);

  g_cond_clear (&context->priv->destroy_cond);
  g_cond_clear (&context->priv->create_cond);

  g_free (context->priv->gl_exts);
  g_weak_ref_clear (&context->priv->other_context_ref);

  GST_DEBUG_OBJECT (context, "End of finalize");
  G_OBJECT_CLASS (gst_gl_context_parent_class)->finalize (object);
}
static gboolean signal_peer_certificate_received(GWeakRef *ref)
{
    GstErDtlsDec *self;

    self = g_weak_ref_get(ref);
    g_weak_ref_clear(ref);
    g_free(ref);
    ref = NULL;

    if (self) {
        g_object_notify_by_pspec(G_OBJECT(self), properties[PROP_PEER_PEM]);
        g_object_unref(self);
        self = NULL;
    }

    return FALSE;
}
示例#17
0
static void
pango_core_text_font_finalize (GObject *object)
{
  PangoCoreTextFont *ctfont = (PangoCoreTextFont *)object;
  PangoCoreTextFontPrivate *priv = ctfont->priv;
  PangoCoreTextFontMap* fontmap = g_weak_ref_get ((GWeakRef *)&priv->fontmap);
  if (fontmap)
    {
      g_weak_ref_clear ((GWeakRef *)&priv->fontmap);
      g_object_unref (fontmap);
    }

  if (priv->coverage)
    pango_coverage_unref (priv->coverage);

  G_OBJECT_CLASS (pango_core_text_font_parent_class)->finalize (object);
}
示例#18
0
static void
gst_gl_display_finalize (GObject * object)
{
  GstGLDisplay *display = GST_GL_DISPLAY (object);
  GList *l;

  GST_TRACE_OBJECT (object, "finalizing");

  for (l = display->priv->contexts; l; l = l->next) {
    g_weak_ref_clear ((GWeakRef *) l->data);
    g_free (l->data);
  }

  g_list_free (display->priv->contexts);

  G_OBJECT_CLASS (gst_gl_display_parent_class)->finalize (object);
}
示例#19
0
/* Properly destroy an ObjRef as it's freed from the hash table */
static void
wref_free_func (gpointer p)
{
	ObjRef *ref = p;
	GObject *obj = g_weak_ref_get (&ref->ref);

	if (obj) {
		/* The object is being removed from the bag while it's
		 * still alive, e.g. by camel_object_bag_remove()
		 * or camel_object_bag_destroy(). Drop the weak_ref. */
		g_object_weak_unref (
			obj, (GWeakNotify) object_bag_notify,
			ref->bag);
		g_object_unref (obj);
	}
	g_weak_ref_clear (&ref->ref);
	g_slice_free (ObjRef, ref);
}
示例#20
0
static void mega_filesystem_finalize(GObject *object)
{
  MegaFilesystem *filesystem = MEGA_FILESYSTEM(object);
  MegaFilesystemPrivate* priv = filesystem->priv;

  g_list_free_full(priv->nodes, (GDestroyNotify)g_object_unref);
  priv->nodes = NULL;

  g_slist_free_full(priv->root_nodes, (GDestroyNotify)g_object_unref);
  priv->root_nodes = NULL;

  g_hash_table_destroy(priv->pathmap);
  g_hash_table_destroy(priv->handlemap);
  g_hash_table_destroy(priv->share_keys);

  g_weak_ref_clear(&priv->session);

  G_OBJECT_CLASS(mega_filesystem_parent_class)->finalize(object);
}
示例#21
0
/*
 * @stmt may be %NULL
 */
static void
gda_stmt_reset_cb (GdaStatement *stmt, GdaPStmt *pstmt)
{
	g_rec_mutex_lock (& pstmt->priv->mutex);
	if (stmt)
		g_signal_handlers_disconnect_by_func (G_OBJECT (stmt),
						      G_CALLBACK (gda_stmt_reset_cb), pstmt);
	else {
		stmt = g_weak_ref_get (& pstmt->priv->gda_stmt_ref);
		if (stmt) {
			g_signal_handlers_disconnect_by_func (G_OBJECT (stmt),
							      G_CALLBACK (gda_stmt_reset_cb), pstmt);
			g_object_unref (stmt);
		}
	}

	g_weak_ref_clear (& pstmt->priv->gda_stmt_ref);
	g_weak_ref_init (& pstmt->priv->gda_stmt_ref, NULL);
	g_rec_mutex_unlock (& pstmt->priv->mutex);
}
示例#22
0
static void
nice_input_stream_dispose (GObject *object)
{
  NiceInputStream *self = NICE_INPUT_STREAM (object);
  NiceAgent *agent;

  /* Ensure the stream is closed first, otherwise the agent can’t be found in
   * the close handler called by the parent implementation. */
  if (!g_input_stream_is_closed (G_INPUT_STREAM (object)))
    g_input_stream_close (G_INPUT_STREAM (object), NULL, NULL);

  agent = g_weak_ref_get (&self->priv->agent_ref);
  if (agent != NULL) {
    g_signal_handlers_disconnect_by_func (agent, streams_removed_cb, self);
    g_object_unref (agent);
  }

  g_weak_ref_clear (&self->priv->agent_ref);

  G_OBJECT_CLASS (nice_input_stream_parent_class)->dispose (object);
}
示例#23
0
static void
gst_gl_window_finalize (GObject * object)
{
  GstGLWindow *window = GST_GL_WINDOW (object);
  GstGLWindowPrivate *priv = window->priv;

  if (priv->loop)
    g_main_loop_unref (priv->loop);

  if (priv->main_context)
    g_main_context_unref (priv->main_context);

  g_weak_ref_clear (&window->context_ref);

  g_mutex_clear (&window->lock);
  g_mutex_clear (&window->priv->sync_message_lock);
  g_cond_clear (&window->priv->sync_message_cond);
  gst_object_unref (window->display);

  G_OBJECT_CLASS (gst_gl_window_parent_class)->finalize (object);
}
示例#24
0
static void
gda_sqlite_blob_op_finalize (GObject * object)
{
	GdaSqliteBlobOp *bop = (GdaSqliteBlobOp *) object;

	g_return_if_fail (GDA_IS_SQLITE_BLOB_OP (bop));
  GdaSqliteBlobOpPrivate *priv = gda_sqlite_blob_op_get_instance_private (bop);

	/* free specific information */
	if (priv->sblob) {
		GdaSqliteProvider *prov = g_weak_ref_get (&priv->provider);
		if (prov != NULL) {
			SQLITE3_CALL (prov, sqlite3_blob_close) (priv->sblob);
			g_object_unref (prov);
		}
#ifdef GDA_DEBUG_NO
		g_print ("CLOSED blob %p\n", bop);
#endif
	}
	g_weak_ref_clear (&priv->provider);

	G_OBJECT_CLASS (gda_sqlite_blob_op_parent_class)->finalize (object);
}
示例#25
0
static void bus_set_value_destroy_func(GWeakRef *ref)
{
    g_weak_ref_clear(ref);
    g_slice_free(GWeakRef, ref);
}
示例#26
0
static void test_refcounting()
{
    OwrBus *bus;
    OwrMessageOrigin *origin;
    GWeakRef weak_ref;
    GAsyncQueue *queue;

    queue = g_async_queue_new();

    bus = owr_bus_new();
    owr_bus_set_message_callback(bus, on_message, queue, NULL);
    origin = mock_origin_new();
    owr_bus_add_message_origin(bus, origin);
    g_weak_ref_init(&weak_ref, bus);
    OWR_POST_STATS(origin, TEST, NULL);
    g_object_unref(bus); /* this should finalize the bus, pending messages should not keep it alive */
    assert_weak_ref(&weak_ref, FALSE, __LINE__);
    g_weak_ref_clear(&weak_ref);

    bus = owr_bus_new();
    owr_bus_set_message_callback(bus, on_message, queue, NULL);
    owr_bus_add_message_origin(bus, origin);
    g_weak_ref_init(&weak_ref, origin);
    OWR_POST_STATS(origin, TEST, NULL);
    g_object_unref(origin); /* the origin should be kept alive though */
    g_object_ref(origin);
    assert_weak_ref(&weak_ref, TRUE, __LINE__);
    g_object_unref(origin);
    g_assert(g_async_queue_timeout_pop(queue, G_USEC_PER_SEC));
    g_usleep(1000); /* messages are cleaned up after all callbacks have happened, so wait a bit more */
    assert_weak_ref(&weak_ref, FALSE, __LINE__); /* but be cleaned up after the message was handled */
    g_weak_ref_clear(&weak_ref);


    /* same as previous tests, but with message filter */
    origin = mock_origin_new();
    owr_bus_add_message_origin(bus, origin);
    g_weak_ref_init(&weak_ref, origin);
    g_object_set(bus, "message-type-mask", OWR_MESSAGE_TYPE_STATS, NULL);
    OWR_POST_STATS(origin, TEST, NULL);
    OWR_POST_EVENT(origin, TEST, NULL);
    OWR_POST_ERROR(origin, TEST, NULL);
    g_object_unref(origin);
    g_object_ref(origin);
    assert_weak_ref(&weak_ref, TRUE, __LINE__);
    g_object_unref(origin);
    g_assert(g_async_queue_timeout_pop(queue, G_USEC_PER_SEC));
    g_usleep(1000);
    assert_weak_ref(&weak_ref, FALSE, __LINE__);
    g_weak_ref_clear(&weak_ref);

    origin = mock_origin_new();
    owr_bus_add_message_origin(bus, origin);
    g_weak_ref_init(&weak_ref, bus);
    OWR_POST_STATS(origin, TEST, NULL);
    OWR_POST_EVENT(origin, TEST, NULL);
    OWR_POST_ERROR(origin, TEST, NULL);
    g_object_unref(bus);
    assert_weak_ref(&weak_ref, FALSE, __LINE__);
    g_weak_ref_clear(&weak_ref);
}
static void
weak_ref_free (GWeakRef * ref)
{
  g_weak_ref_clear (ref);
  g_slice_free (GWeakRef, ref);
}