mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-15 20:18:05 +02:00
Merge branch 'ebassi/issue-3130' into 'main'
Check for empty property name in GPropertyAction Closes #3130 See merge request GNOME/glib!3599
This commit is contained in:
commit
86fdb4c7bf
@ -313,6 +313,15 @@ g_property_action_set_property_name (GPropertyAction *paction,
|
|||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
gchar *detailed;
|
gchar *detailed;
|
||||||
|
|
||||||
|
/* In case somebody is constructing GPropertyAction without passing
|
||||||
|
* a property name
|
||||||
|
*/
|
||||||
|
if (G_UNLIKELY (property_name == NULL || property_name[0] == '\0'))
|
||||||
|
{
|
||||||
|
g_critical ("Attempted to use an empty property name for GPropertyAction");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (paction->object), property_name);
|
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (paction->object), property_name);
|
||||||
|
|
||||||
if (pspec == NULL)
|
if (pspec == NULL)
|
||||||
@ -407,13 +416,25 @@ g_property_action_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_property_action_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GPropertyAction *paction = G_PROPERTY_ACTION (object);
|
||||||
|
|
||||||
|
if (paction->object != NULL)
|
||||||
|
{
|
||||||
|
g_signal_handlers_disconnect_by_func (paction->object, g_property_action_notify, paction);
|
||||||
|
g_clear_object (&paction->object);
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (g_property_action_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_property_action_finalize (GObject *object)
|
g_property_action_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
GPropertyAction *paction = G_PROPERTY_ACTION (object);
|
GPropertyAction *paction = G_PROPERTY_ACTION (object);
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (paction->object, g_property_action_notify, paction);
|
|
||||||
g_object_unref (paction->object);
|
|
||||||
g_free (paction->name);
|
g_free (paction->name);
|
||||||
|
|
||||||
G_OBJECT_CLASS (g_property_action_parent_class)
|
G_OBJECT_CLASS (g_property_action_parent_class)
|
||||||
@ -445,6 +466,7 @@ g_property_action_class_init (GPropertyActionClass *class)
|
|||||||
|
|
||||||
object_class->set_property = g_property_action_set_property;
|
object_class->set_property = g_property_action_set_property;
|
||||||
object_class->get_property = g_property_action_get_property;
|
object_class->get_property = g_property_action_get_property;
|
||||||
|
object_class->dispose = g_property_action_dispose;
|
||||||
object_class->finalize = g_property_action_finalize;
|
object_class->finalize = g_property_action_finalize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1421,6 +1421,20 @@ test_property_actions (void)
|
|||||||
g_object_unref (group);
|
g_object_unref (group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_property_actions_no_properties (void)
|
||||||
|
{
|
||||||
|
GPropertyAction *action;
|
||||||
|
|
||||||
|
g_test_expect_message ("GLib-GIO", G_LOG_LEVEL_CRITICAL, "*Attempted to use an empty property name for GPropertyAction*");
|
||||||
|
action = (GPropertyAction*) g_object_new_with_properties (G_TYPE_PROPERTY_ACTION, 0, NULL, NULL);
|
||||||
|
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
g_assert_true (G_IS_PROPERTY_ACTION (action));
|
||||||
|
|
||||||
|
g_object_unref (action);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -1437,6 +1451,7 @@ main (int argc, char **argv)
|
|||||||
g_test_add_func ("/actions/dbus/threaded", test_dbus_threaded);
|
g_test_add_func ("/actions/dbus/threaded", test_dbus_threaded);
|
||||||
g_test_add_func ("/actions/dbus/bug679509", test_bug679509);
|
g_test_add_func ("/actions/dbus/bug679509", test_bug679509);
|
||||||
g_test_add_func ("/actions/property", test_property_actions);
|
g_test_add_func ("/actions/property", test_property_actions);
|
||||||
|
g_test_add_func ("/actions/no-properties", test_property_actions_no_properties);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user