From b2371871097ef2b52bdb4688d702438c9e3f1787 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Tue, 20 Dec 2011 19:43:21 -0500 Subject: [PATCH] GObject: require READ or WRITE on property install g_object_class_install_property() currently lets you install properties that are neither readable nor writable. Add a check to prevent that. https://bugzilla.gnome.org/show_bug.cgi?id=666616 --- gobject/gobject.c | 1 + gobject/tests/param.c | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/gobject/gobject.c b/gobject/gobject.c index b0fe218..446ea4a 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -530,6 +530,7 @@ g_object_class_install_property (GObjectClass *class, class->flags |= CLASS_HAS_PROPS_FLAG; + g_return_if_fail (pspec->flags & (G_PARAM_READABLE | G_PARAM_WRITABLE)); if (pspec->flags & G_PARAM_WRITABLE) g_return_if_fail (class->set_property != NULL); if (pspec->flags & G_PARAM_READABLE) diff --git a/gobject/tests/param.c b/gobject/tests/param.c index 912bfa5..2250d61 100644 --- a/gobject/tests/param.c +++ b/gobject/tests/param.c @@ -687,9 +687,6 @@ static void test_implementation_class_init (TestImplementationClass *class) if (perms[change_this_flag] == NULL) g_error ("Interface property does not exist"); - if (!(use_this_flag & (G_PARAM_READABLE | G_PARAM_WRITABLE))) - g_error ("g_object_class_install_property should probably fail here..."); - g_snprintf (prop_name, sizeof prop_name, "%s-%s", names[change_this_type], perms[change_this_flag]); pspec = g_param_spec_object (prop_name, prop_name, prop_name, types[use_this_type], use_this_flag); g_object_class_install_property (class, 1, pspec); -- 2.7.4