aboutsummaryrefslogtreecommitdiff
path: root/qobject/qdict.c
diff options
context:
space:
mode:
Diffstat (limited to 'qobject/qdict.c')
-rw-r--r--qobject/qdict.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/qobject/qdict.c b/qobject/qdict.c
index 0f3e0a6c81..17e14f08b1 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -481,7 +481,7 @@ static void qdict_do_flatten(QDict *qdict, QDict *target, const char *prefix)
{
QObject *value;
const QDictEntry *entry, *next;
- const char *new_key;
+ char *new_key;
bool delete;
entry = qdict_first(qdict);
@@ -494,18 +494,24 @@ static void qdict_do_flatten(QDict *qdict, QDict *target, const char *prefix)
delete = false;
if (prefix) {
- qobject_incref(value);
new_key = g_strdup_printf("%s.%s", prefix, entry->key);
- qdict_put_obj(target, new_key, value);
- delete = true;
}
if (qobject_type(value) == QTYPE_QDICT) {
+ /* Entries of QDicts are processed recursively, the QDict object
+ * itself disappears. */
qdict_do_flatten(qobject_to_qdict(value), target,
new_key ? new_key : entry->key);
delete = true;
+ } else if (prefix) {
+ /* All other objects are moved to the target unchanged. */
+ qobject_incref(value);
+ qdict_put_obj(target, new_key, value);
+ delete = true;
}
+ g_free(new_key);
+
if (delete) {
qdict_del(qdict, entry->key);