mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-30 20:16:52 +00:00
qdict: Make qdict_get_qlist() safe like qdict_get_qdict()
Commit 89cad9f changed qdict_get_qdict() to return NULL instead of crash when the key doesn't exist or its value isn't a QDict. Commit 2d6421a neglected to do the same for qdict_get_qlist(). Correct that, and update the function comments. qdict_get_obj() is now unused, remove. Backports commit b25f23e7dbc6bc0dcda010222a4f178669d1aedc from qemu
This commit is contained in:
parent
7fadaf0bc4
commit
9d1937f25d
|
@ -177,20 +177,6 @@ size_t qdict_size(const QDict *qdict)
|
||||||
return qdict->size;
|
return qdict->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* qdict_get_obj(): Get a QObject of a specific type
|
|
||||||
*/
|
|
||||||
static QObject *qdict_get_obj(const QDict *qdict, const char *key, QType type)
|
|
||||||
{
|
|
||||||
QObject *obj;
|
|
||||||
|
|
||||||
obj = qdict_get(qdict, key);
|
|
||||||
assert(obj != NULL);
|
|
||||||
assert(qobject_type(obj) == type);
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qdict_get_double(): Get an number mapped by 'key'
|
* qdict_get_double(): Get an number mapped by 'key'
|
||||||
*
|
*
|
||||||
|
@ -241,25 +227,15 @@ bool qdict_get_bool(const QDict *qdict, const char *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qdict_get_qlist(): Get the QList mapped by 'key'
|
* qdict_get_qlist(): If @qdict maps @key to a QList, return it, else NULL.
|
||||||
*
|
|
||||||
* This function assumes that 'key' exists and it stores a
|
|
||||||
* QList object.
|
|
||||||
*
|
|
||||||
* Return QList mapped by 'key'.
|
|
||||||
*/
|
*/
|
||||||
QList *qdict_get_qlist(const QDict *qdict, const char *key)
|
QList *qdict_get_qlist(const QDict *qdict, const char *key)
|
||||||
{
|
{
|
||||||
return qobject_to_qlist(qdict_get_obj(qdict, key, QTYPE_QLIST));
|
return qobject_to_qlist(qdict_get(qdict, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qdict_get_qdict(): Get the QDict mapped by 'key'
|
* qdict_get_qdict(): If @qdict maps @key to a QDict, return it, else NULL.
|
||||||
*
|
|
||||||
* This function assumes that 'key' exists and it stores a
|
|
||||||
* QDict object.
|
|
||||||
*
|
|
||||||
* Return QDict mapped by 'key'.
|
|
||||||
*/
|
*/
|
||||||
QDict *qdict_get_qdict(const QDict *qdict, const char *key)
|
QDict *qdict_get_qdict(const QDict *qdict, const char *key)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue