diff options
author | Chris Coulson <chris.coulson@canonical.com> | 2013-05-29 15:44:22 +0000 |
---|---|---|
committer | Tarmac <Unknown> | 2013-05-29 15:44:22 +0000 |
commit | 4838bf84e39dccb6af71cf266438aaf49eea55d2 (patch) | |
tree | 68def63e628a34f0b9a0539298948f93ae89f1b3 | |
parent | 404198e78252143ef700f9a419c351e3042620e2 (diff) | |
parent | 09ce53603cda79824123867e8ea11af94be81eec (diff) | |
download | libdbusmenu-4838bf84e39dccb6af71cf266438aaf49eea55d2.tar.gz libdbusmenu-4838bf84e39dccb6af71cf266438aaf49eea55d2.tar.bz2 libdbusmenu-4838bf84e39dccb6af71cf266438aaf49eea55d2.zip |
Fix the long-standing "nm-applet stops working after a few days / hours" issue; properly handle "unique" IDs for indicator menuitems. Fixes: https://bugs.launchpad.net/bugs/1011073.
Approved by Ted Gould, PS Jenkins bot, Mathieu Trudel-Lapierre.
-rw-r--r-- | libdbusmenu-glib/menuitem.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index cd9f978..0b85193 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,11 @@ 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; + if (priv->id == G_MAXINT) { + menuitem_next_id = 1; + } else { + menuitem_next_id = priv->id + 1; + } } break; default: @@ -410,7 +414,12 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) switch (id) { case PROP_ID: if (priv->id == -1) { - priv->id = menuitem_next_id++; + priv->id = menuitem_next_id; + if (menuitem_next_id == G_MAXINT) { + menuitem_next_id = 1; + } else { + menuitem_next_id += 1; + } } if (dbusmenu_menuitem_get_root(DBUSMENU_MENUITEM(obj))) { g_value_set_int(value, 0); |