[gnome-builder] diagnostics-manager: don't leak GWeakRef objects
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] diagnostics-manager: don't leak GWeakRef objects
- Date: Fri, 28 Oct 2016 23:37:40 +0000 (UTC)
commit c34a2d1bc78c1c745944119691c29cf23d0149a7
Author: Christian Hergert <chergert redhat com>
Date: Fri Oct 28 16:37:32 2016 -0700
diagnostics-manager: don't leak GWeakRef objects
These return a full object reference, so we need to use an autoptr to
release them when we no longer use them.
libide/diagnostics/ide-diagnostics-manager.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/libide/diagnostics/ide-diagnostics-manager.c b/libide/diagnostics/ide-diagnostics-manager.c
index 366d201..bcbfd52 100644
--- a/libide/diagnostics/ide-diagnostics-manager.c
+++ b/libide/diagnostics/ide-diagnostics-manager.c
@@ -250,6 +250,8 @@ ide_diagnostics_group_has_diagnostics (IdeDiagnosticsGroup *group)
static gboolean
ide_diagnostics_group_can_dispose (IdeDiagnosticsGroup *group)
{
+ g_autoptr(IdeBuffer) buffer = NULL;
+
g_assert (group != NULL);
/*
@@ -258,7 +260,9 @@ ide_diagnostics_group_can_dispose (IdeDiagnosticsGroup *group)
* registered for the group.
*/
- return (g_weak_ref_get (&group->buffer_wr) == NULL) &&
+ buffer = g_weak_ref_get (&group->buffer_wr);
+
+ return (buffer == NULL) &&
(group->adapter == NULL) &&
(group->has_diagnostics == FALSE);
}
@@ -443,7 +447,7 @@ static void
ide_diagnostics_group_diagnose (IdeDiagnosticsGroup *group,
IdeDiagnosticsManager *self)
{
- IdeBuffer *buffer;
+ g_autoptr(IdeBuffer) buffer = NULL;
IDE_ENTRY;
@@ -892,8 +896,9 @@ ide_diagnostics_manager_buffer_notify_file (IdeDiagnosticsManager *self,
while (g_hash_table_iter_next (&iter, NULL, &value))
{
IdeDiagnosticsGroup *group = value;
+ g_autoptr(IdeBuffer) group_buffer = g_weak_ref_get (&group->buffer_wr);
- if (buffer == g_weak_ref_get (&group->buffer_wr))
+ if (buffer == group_buffer)
{
g_hash_table_steal (self->groups_by_file, group->file);
g_set_object (&group->file, gfile);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]