summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-09-27 17:41:36 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-09-28 12:12:43 +0100
commit7fcaf6c8c6d0e6ade0e8d5460b5311b564a24d3f (patch)
tree9cfc1207a4b524cb824e1509f60c77271b0683d1
parent58ed26382bf23fe9fb592d38b5be2c2c7b2e77e2 (diff)
dbus-gtype-specialized: warn if vtables have missing callbacks
It's just about conceivable that they wouldn't segfault, if application authors carefully avoided the unimplemented functionality... but still. Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37793 Bug-NB: related to NB#218973
-rw-r--r--dbus/dbus-gtype-specialized.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/dbus/dbus-gtype-specialized.c b/dbus/dbus-gtype-specialized.c
index 4964c4b..84efaf6 100644
--- a/dbus/dbus-gtype-specialized.c
+++ b/dbus/dbus-gtype-specialized.c
@@ -260,7 +260,13 @@ register_container (const char *name,
const DBusGTypeSpecializedVtable *vtable)
{
DBusGTypeSpecializedContainer *klass;
-
+
+ g_warn_if_fail (vtable->constructor != NULL);
+ /* must have either free_func or simple_free_func */
+ g_warn_if_fail (vtable->free_func != NULL ||
+ vtable->simple_free_func != NULL);
+ g_warn_if_fail (vtable->copy_func != NULL);
+
klass = g_new0 (DBusGTypeSpecializedContainer, 1);
klass->type = type;
klass->vtable = vtable;
@@ -291,6 +297,11 @@ _dbus_g_type_register_collection (const char *
const DBusGTypeSpecializedCollectionVtable *vtable,
guint flags)
{
+ /* fixed_accessor is optional */
+ g_warn_if_fail (vtable->iterator != NULL);
+ g_warn_if_fail (vtable->append_func != NULL);
+ /* end_append_func is optional */
+
register_container (name, DBUS_G_SPECTYPE_COLLECTION, (const DBusGTypeSpecializedVtable*) vtable);
}
@@ -317,6 +328,9 @@ _dbus_g_type_register_map (const char *name,
const DBusGTypeSpecializedMapVtable *vtable,
guint flags)
{
+ g_warn_if_fail (vtable->iterator != NULL);
+ g_warn_if_fail (vtable->append_func != NULL);
+
register_container (name, DBUS_G_SPECTYPE_MAP, (const DBusGTypeSpecializedVtable*) vtable);
}
@@ -343,6 +357,9 @@ _dbus_g_type_register_struct (const char *name,
const DBusGTypeSpecializedStructVtable *vtable,
guint flags)
{
+ g_warn_if_fail (vtable->get_member != NULL);
+ g_warn_if_fail (vtable->set_member != NULL);
+
register_container (name, DBUS_G_SPECTYPE_STRUCT, (const DBusGTypeSpecializedVtable*) vtable);
}