Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attributes Form, Value relation broken #42003

Closed
stefan-overkamp opened this issue Mar 3, 2021 · 3 comments · Fixed by #42031
Closed

Attributes Form, Value relation broken #42003

stefan-overkamp opened this issue Mar 3, 2021 · 3 comments · Fixed by #42031
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Forms Regression Something which used to work, but doesn't anymore

Comments

@stefan-overkamp
Copy link

Describe the bug

QGIS Attribute Forms with value relations show different values then in Identify result dialog and database.

How to Reproduce

project file and geopackage
https://geodaten.metropoleruhr.de/owncloud/s/N8S98l96zCFeIQL

  1. Select Layer radwege
  2. Activate feature identify tool and click on a feature
  3. Open the features form
  4. Compare the value of field Status (e.g. in Betrieb (use)) in identify result dialog and form
  5. The form doesn't show correct values, value relations with 1:n configured show no matches
  6. Setting the layer to edit mode shows correct values but closing and opening the form again shows false values again

QGIS and OS versions

QGIS-Version 3.18.0-Zürich QGIS-Codeversion bdef9fb
Kompiliert gegen Qt 5.15.2
Windows 10, Version 1909

There is no problem with value relations on:
QGIS-Version 3.16.4-Hannover QGIS-Codeversion 654e76b

@stefan-overkamp stefan-overkamp added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Mar 3, 2021
@stefan-overkamp
Copy link
Author

value_relation_broken

@gioman gioman added Regression Something which used to work, but doesn't anymore Forms labels Mar 3, 2021
@gioman gioman changed the title QGIS 3.18: Attributes Form, Value relation broken Attributes Form, Value relation broken Mar 3, 2021
@roya0045
Copy link
Contributor

roya0045 commented Mar 3, 2021

@suricactus do you know if some of your changes might be related to this or could it be something else?

@elpaso
Copy link
Contributor

elpaso commented Mar 3, 2021

This fixes the issue for me but I'd like to know what was changed to trigger this issue in the first place

diff --git a/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp b/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
index df790af9fc..3fa2aa4a4d 100644
--- a/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
+++ b/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
@@ -325,7 +325,7 @@ void QgsValueRelationWidgetWrapper::setFeature( const QgsFeature &feature )
     {
       if ( ! mCache.isEmpty() )
       {
-        updateValues( mCache.at( 0 ).key );
+        updateValues( formFeature().attribute( fieldIdx() ).isValid() ? formFeature().attribute( fieldIdx() ) : mCache.at( 0 ).key );
       }
     } );
   }

@elpaso elpaso self-assigned this Mar 4, 2021
elpaso added a commit to elpaso/QGIS that referenced this issue Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Forms Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants