ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #03152
[Branch ~dbusmenu-team/dbusmenu/trunk] Rev 221: Don't check defaults with NULL objects
Merge authors:
Ted Gould (ted)
Related merge proposals:
https://code.launchpad.net/~ted/dbusmenu/null-protect-when-set/+merge/50977
proposed by: Ted Gould (ted)
review: Approve - Conor Curran (cjcurran)
------------------------------------------------------------
revno: 221 [merge]
committer: Ted Gould <ted@xxxxxxxx>
branch nick: trunk
timestamp: Wed 2011-02-23 15:00:33 -0600
message:
Don't check defaults with NULL objects
modified:
libdbusmenu-glib/menuitem.c
--
lp:dbusmenu
https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk
Your team ayatana-commits is subscribed to branch lp:dbusmenu.
To unsubscribe from this branch go to https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk/+edit-subscription
=== modified file 'libdbusmenu-glib/menuitem.c'
--- libdbusmenu-glib/menuitem.c 2011-02-22 03:41:54 +0000
+++ libdbusmenu-glib/menuitem.c 2011-02-23 19:24:04 +0000
@@ -1025,31 +1025,34 @@
g_return_val_if_fail(property != NULL, FALSE);
DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
-
- const gchar * type = menuitem_get_type(mi);
-
- /* Check the expected type to see if we want to have a warning */
- GVariantType * default_type = dbusmenu_defaults_default_get_type(priv->defaults, type, property);
- if (default_type != NULL) {
- /* If we have an expected type we should check to see if
- the value we've been given is of the same type and generate
- a warning if it isn't */
- if (!g_variant_is_of_type(value, default_type)) {
- g_warning("Setting menuitem property '%s' with value of type '%s' when expecting '%s'", property, g_variant_get_type_string(value), g_variant_type_peek_string(default_type));
+ GVariant * default_value = NULL;
+
+ if (value != NULL) {
+ const gchar * type = menuitem_get_type(mi);
+
+ /* Check the expected type to see if we want to have a warning */
+ GVariantType * default_type = dbusmenu_defaults_default_get_type(priv->defaults, type, property);
+ if (default_type != NULL) {
+ /* If we have an expected type we should check to see if
+ the value we've been given is of the same type and generate
+ a warning if it isn't */
+ if (!g_variant_is_of_type(value, default_type)) {
+ g_warning("Setting menuitem property '%s' with value of type '%s' when expecting '%s'", property, g_variant_get_type_string(value), g_variant_type_peek_string(default_type));
+ }
}
- }
- /* Check the defaults database to see if we have a default
- for this property. */
- GVariant * default_value = dbusmenu_defaults_default_get(priv->defaults, type, property);
- if (default_value != NULL) {
- /* Now see if we're setting this to the same value as the
- default. If we are then we just want to swallow this variant
- and make the function behave like we're clearing it. */
- if (g_variant_equal(default_value, value)) {
- g_variant_ref_sink(value);
- g_variant_unref(value);
- value = NULL;
+ /* Check the defaults database to see if we have a default
+ for this property. */
+ default_value = dbusmenu_defaults_default_get(priv->defaults, type, property);
+ if (default_value != NULL) {
+ /* Now see if we're setting this to the same value as the
+ default. If we are then we just want to swallow this variant
+ and make the function behave like we're clearing it. */
+ if (g_variant_equal(default_value, value)) {
+ g_variant_ref_sink(value);
+ g_variant_unref(value);
+ value = NULL;
+ }
}
}