Properties are associated with a specific interface, although the Solid
UDisks2 backend merges properties from all interfaces into a single
namespace.
Fortunately most properties have either unique names accross interfaces,
or are consistent (e.g. "Size" in org.fd.UDisks2.{Block,Partition}), thus
this poses no problem in practice.
QMap<>::unite(other) behaves like QMap<>::insertMulti(item), i.e. the
map may contain multiple values per key, while QMap<>::insert(item)
updates the value for existing keys.
Details
- Reviewers
broulik - Group Reviewers
Frameworks - Commits
- R245:15047128e56b: Avoid creating duplicate property entries in the cache
make
solid-hardware list details
Diff Detail
- Repository
- R245 Solid
- Branch
- unique_properties
- Lint
No Linters Available - Unit
No Unit Test Coverage
Wouldn't make a big difference, would it?
If there are multiple items for key in the map, the value of the most recently inserted one is returned.
It's not like we actually check for the property we're overriding with having a saner value.
As allproperties is currently called directly from Manager::updateBackend (which is IMHO wrong and needs some cleanup), we end up with values from multiple GetAll calls for the same interface. Without the "cleanup after InterfaceRemoved" (D12126), the propertyCache for e.g. Loop interfaces contained each key 4 times, after D12126 its only twice without this one.
Fortunately QMap guarantees to use the last inserted value when there are multiple values for a key [1], so this is likely only annoying when debugging and a slight waste of memory/cpu time.
[1] http://doc.qt.io/qt-5/qmap.html#find