~dbusmenu-team/libdbusmenu/ubuntu

« back to all changes in this revision

Viewing changes to libdbusmenu-glib/menuitem.c

Tags: 0.3.100-0ubuntu3
releasing version 0.3.100-0ubuntu3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1180
1180
                }
1181
1181
        }
1182
1182
 
1183
 
 
1184
1183
        gboolean replaced = FALSE;
1185
1184
        gboolean remove = FALSE;
1186
 
        gpointer currentval = g_hash_table_lookup(priv->properties, property);
 
1185
        gchar * hash_key = NULL;
 
1186
        GVariant * hash_variant = NULL;
 
1187
        gboolean inhash = g_hash_table_lookup_extended(priv->properties, property, (gpointer *)&hash_key, (gpointer *)&hash_variant);
 
1188
 
 
1189
        if (inhash && hash_variant == NULL) {
 
1190
                g_warning("The property '%s' is in the hash with a NULL variant", property);
 
1191
                inhash = FALSE;
 
1192
        }
1187
1193
 
1188
1194
        if (value != NULL) {
1189
1195
                /* NOTE: We're only marking this as replaced if this is true
1190
1196
                   but we're actually replacing it no matter.  This is so that
1191
1197
                   the variant passed in sticks around which the caller may
1192
1198
                   expect.  They shouldn't, but it's low cost to remove bugs. */
1193
 
                if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) {
 
1199
                if (!inhash || !g_variant_equal(hash_variant, value)) {
1194
1200
                        replaced = TRUE;
1195
1201
                }
1196
1202
 
1204
1210
                   bad value */
1205
1211
                g_hash_table_insert(priv->properties, lprop, value);
1206
1212
        } else {
1207
 
                if (currentval != NULL) {
 
1213
                if (inhash) {
1208
1214
                /* So the question you should be asking if you're paying attention
1209
1215
                   is "Why not just do the remove here?"  It's a good question with
1210
1216
                   an interesting answer.  Bascially it's the same reason as above,
1213
1219
                   it) after the signal emition */
1214
1220
                        remove = TRUE;
1215
1221
                        replaced = TRUE;
 
1222
                        g_hash_table_steal(priv->properties, property);
1216
1223
                }
1217
1224
        }
1218
1225
 
1220
1227
           becuse it has been unref'd when replaced in the hash
1221
1228
           table.  But the fact that there was a value is
1222
1229
           the imporant part. */
1223
 
        if (currentval == NULL || replaced) {
 
1230
        if (!inhash || replaced) {
1224
1231
                GVariant * signalval = value;
1225
1232
 
1226
1233
                if (signalval == NULL) {
1233
1240
        }
1234
1241
 
1235
1242
        if (remove) {
1236
 
                g_hash_table_remove(priv->properties, property);
 
1243
                g_free(hash_key);
 
1244
                g_variant_unref(hash_variant);
1237
1245
        }
1238
1246
 
1239
1247
        return TRUE;