mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
util/list_model.h: graceful handling of duplicates
This patch makes the 'List_model' utility robust against duplicated occurrences of node IDs in the supplied XML data. If two or more XML nodes correspond to the same model element, the existing element is updated with the information of the subsequent XML nodes.
This commit is contained in:
parent
bf52f73d03
commit
24e6b677bd
@ -135,6 +135,16 @@ void Genode::List_model<ELEM>::update_from_xml(POLICY &policy, Xml_node node)
|
||||
if (!policy.node_is_element(sub_node))
|
||||
return;
|
||||
|
||||
/* check for duplicates, which must not exist in the list model */
|
||||
for (Element *dup = updated_list.first(); dup; dup = dup->_next()) {
|
||||
|
||||
/* update existing element with information from later node */
|
||||
if (policy.element_matches_xml_node(*dup, sub_node)) {
|
||||
policy.update_element(*dup, sub_node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* look up corresponding element in original list */
|
||||
Element *curr = _elements.first();
|
||||
while (curr && !policy.element_matches_xml_node(*curr, sub_node))
|
||||
|
Loading…
x
Reference in New Issue
Block a user