aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
authorChris Coulson <chris.coulson@canonical.com>2013-05-17 22:30:19 +0100
committerChris Coulson <chris.coulson@canonical.com>2013-05-17 22:30:19 +0100
commitec9f767eac6b83d1dbf7200cddc1dbe81a9d11d7 (patch)
tree9ebbd1108e42920f8b508ca5e7edfc5373f2e4e5 /libdbusmenu-glib
parent404198e78252143ef700f9a419c351e3042620e2 (diff)
downloadlibdbusmenu-ec9f767eac6b83d1dbf7200cddc1dbe81a9d11d7.tar.gz
libdbusmenu-ec9f767eac6b83d1dbf7200cddc1dbe81a9d11d7.tar.bz2
libdbusmenu-ec9f767eac6b83d1dbf7200cddc1dbe81a9d11d7.zip
Set the max ID of menuitems to G_MAXINT rather than 30000, as internally, the server side happily creates ID's greater than this which then wraparound on the client side.
We keep the minimum unchanged at -1, as some consumers addume that < 0 is an error (rather than -1). To make this a bit less fragile, handle rollover on the server side from G_MAXINT to 1, rather than having a signed integer overflow which will just break things a bit later on
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/menuitem.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index cd9f978..536fd6d 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -270,7 +270,7 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass)
g_object_class_install_property (object_class, PROP_ID,
g_param_spec_int(PROP_ID_S, "ID for the menu item",
"This is a unique indentifier for the menu item.",
- -1, 30000, -1,
+ -1, G_MAXINT, -1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
/* Check transfer functions for GValue */
@@ -391,7 +391,8 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec)
case PROP_ID:
priv->id = g_value_get_int(value);
if (priv->id > menuitem_next_id) {
- menuitem_next_id = priv->id + 1;
+ menuitem_next_id = (priv->id + 1) % G_MAXINT;
+ if (menuitem_next_id == 0) menuitem_next_id++;
}
break;
default:
@@ -411,6 +412,8 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec)
case PROP_ID:
if (priv->id == -1) {
priv->id = menuitem_next_id++;
+ menuitem_next_id &= G_MAXINT;
+ if (menuitem_next_id == 0) menuitem_next_id++;
}
if (dbusmenu_menuitem_get_root(DBUSMENU_MENUITEM(obj))) {
g_value_set_int(value, 0);