Bug report #15223
PostgreSQL provider broken under Qt5
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||23160|
The PostgreSQL provider is broken under Qt5 builds- it is impossible to select a single feature and the attribute table shows all repeating features.
I've tracked this down to QgsPostgresSharedData::lookupFid. Basically, what is happening is that the QMap<QVariant, QgsFeatureId> lookup does not work under Qt5, and in the block:
QMap<QVariant, QgsFeatureId>::const_iterator it = mKeyToFid.constFind( v );
if ( it != mKeyToFid.constEnd() )
it will never be constEnd, even when the key is NOT present in the map, it will instead just return the first item in the map. I believe this is due to a broken < operator for QVariant of list types under qt5.
Marking this as a blocker, but not for 2.16
Fix postgres pkey map in Qt5 (fixes #15223)
Switching from QVariant to QVariantList solves the underlying Qt issue:
- comparison of QVariantList objects works fine
- comparison of QVariantList objects wrapped in QVariant does not work
The extra wrapping of QVariantList into another QVariant seems unnecessary anyway,
so we may as well save a tiny bit of memory and cpu
#1 Updated by Denis Rouzaud about 4 years ago
Is that the difference pointed in Qt doc:
In the case of custom types, their equalness operators are not called. Instead the values' addresses are compared.
Warning: To make this function work with a custom type registered with qRegisterMetaType(), its comparison operator must be registered using QMetaType::registerComparators().
Is this the solution: registering the comparator for QgsFeatureId?