[gtk/matthiasc/for-master] Fix leaks in tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] Fix leaks in tests
- Date: Wed, 4 Dec 2019 23:09:46 +0000 (UTC)
commit 38851cbcb3dc651e81357cc84ec19108551b2215
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Dec 4 07:51:04 2019 -0500
Fix leaks in tests
All the list model tests were leaking items,
because g_list_model_get_item is transfer full.
Fixing these unveils a crash in the treelistmodel
and maplistmodel tests.
testsuite/gtk/filterlistmodel.c | 5 ++++-
testsuite/gtk/flattenlistmodel.c | 5 ++++-
testsuite/gtk/maplistmodel.c | 5 ++++-
testsuite/gtk/slicelistmodel.c | 5 ++++-
testsuite/gtk/sortlistmodel.c | 5 ++++-
testsuite/gtk/treelistmodel.c | 5 ++++-
6 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/testsuite/gtk/filterlistmodel.c b/testsuite/gtk/filterlistmodel.c
index 6cd9111255..35ddfde052 100644
--- a/testsuite/gtk/filterlistmodel.c
+++ b/testsuite/gtk/filterlistmodel.c
@@ -29,8 +29,11 @@ get (GListModel *model,
guint position)
{
GObject *object = g_list_model_get_item (model, position);
+ guint number;
g_assert (object != NULL);
- return GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ number = GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ g_object_unref (object);
+ return number;
}
static char *
diff --git a/testsuite/gtk/flattenlistmodel.c b/testsuite/gtk/flattenlistmodel.c
index 79921e5042..8851097dc5 100644
--- a/testsuite/gtk/flattenlistmodel.c
+++ b/testsuite/gtk/flattenlistmodel.c
@@ -29,8 +29,11 @@ get (GListModel *model,
guint position)
{
GObject *object = g_list_model_get_item (model, position);
+ guint number;
g_assert (object != NULL);
- return GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ number = GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ g_object_unref (object);
+ return number;
}
static char *
diff --git a/testsuite/gtk/maplistmodel.c b/testsuite/gtk/maplistmodel.c
index 11f87f0d37..5b6af7b5e4 100644
--- a/testsuite/gtk/maplistmodel.c
+++ b/testsuite/gtk/maplistmodel.c
@@ -29,8 +29,11 @@ get (GListModel *model,
guint position)
{
GObject *object = g_list_model_get_item (model, position);
+ guint number;
g_assert (object != NULL);
- return GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ number = GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ g_object_unref (object);
+ return number;
}
static char *
diff --git a/testsuite/gtk/slicelistmodel.c b/testsuite/gtk/slicelistmodel.c
index a672feeac8..48619c4f82 100644
--- a/testsuite/gtk/slicelistmodel.c
+++ b/testsuite/gtk/slicelistmodel.c
@@ -28,8 +28,11 @@ get (GListModel *model,
guint position)
{
GObject *object = g_list_model_get_item (model, position);
+ guint number;
g_assert (object != NULL);
- return GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ number = GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ g_object_unref (object);
+ return number;
}
static char *
diff --git a/testsuite/gtk/sortlistmodel.c b/testsuite/gtk/sortlistmodel.c
index 03b5c8ad64..1fb430aafb 100644
--- a/testsuite/gtk/sortlistmodel.c
+++ b/testsuite/gtk/sortlistmodel.c
@@ -29,8 +29,11 @@ get (GListModel *model,
guint position)
{
GObject *object = g_list_model_get_item (model, position);
+ guint number;
g_assert (object != NULL);
- return GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ number = GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ g_object_unref (object);
+ return number;
}
static char *
diff --git a/testsuite/gtk/treelistmodel.c b/testsuite/gtk/treelistmodel.c
index a54d869aa3..3a0d6df674 100644
--- a/testsuite/gtk/treelistmodel.c
+++ b/testsuite/gtk/treelistmodel.c
@@ -29,8 +29,11 @@ get (GListModel *model,
guint position)
{
GObject *object = g_list_model_get_item (model, position);
+ guint number;
g_assert (object != NULL);
- return GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ number = GPOINTER_TO_UINT (g_object_get_qdata (object, number_quark));
+ g_object_unref (object);
+ return number;
}
static char *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]