[glib: 2/5] gliststore: Simplify a GType check on construction
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/5] gliststore: Simplify a GType check on construction
- Date: Wed, 5 Sep 2018 11:12:23 +0000 (UTC)
commit 35d1ef678aacdf9e7b616465e5ce20368f4f106e
Author: Philip Withnall <withnall endlessm com>
Date: Wed Sep 5 11:25:58 2018 +0100
gliststore: Simplify a GType check on construction
When setting the GListStore:item-type property we need to check the
GType is a GObject (or subclass). There was some explicit code for this,
but when actually testing it and looking at the code coverage, it turns
out that the GObject property type check coming from
g_param_spec_gtype() does everything we want, and the custom
g_critical() can never be hit. So turn it into an assertion.
Signed-off-by: Philip Withnall <withnall endlessm com>
gio/gliststore.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
---
diff --git a/gio/gliststore.c b/gio/gliststore.c
index c91dcb334..8d9fbfe35 100644
--- a/gio/gliststore.c
+++ b/gio/gliststore.c
@@ -125,10 +125,8 @@ g_list_store_set_property (GObject *object,
switch (property_id)
{
case PROP_ITEM_TYPE: /* construct-only */
+ g_assert (g_type_is_a (g_value_get_gtype (value), G_TYPE_OBJECT));
store->item_type = g_value_get_gtype (value);
- if (!g_type_is_a (store->item_type, G_TYPE_OBJECT))
- g_critical ("GListStore cannot store items of type '%s'. Items must be GObjects.",
- g_type_name (store->item_type));
break;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]