Skip to content

Commit

Permalink
Handle NULL case in value map when NULL is not in the map
Browse files Browse the repository at this point in the history
Corner case of bug #32756, handles (NULL) value
when NULL is not in the map of allowed values.

NULL is shown as (NULL) instead of <NULL> in this case.
  • Loading branch information
elpaso committed Jun 8, 2020
1 parent 59ce5c8 commit bc0f478
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gui/editorwidgets/qgsvaluemapwidgetwrapper.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "qgsvaluemapwidgetwrapper.h" #include "qgsvaluemapwidgetwrapper.h"
#include "qgsvaluemapconfigdlg.h" #include "qgsvaluemapconfigdlg.h"
#include "qgsvaluemapfieldformatter.h" #include "qgsvaluemapfieldformatter.h"
#include "qgsapplication.h"


#include <QSettings> #include <QSettings>


Expand Down Expand Up @@ -81,7 +82,14 @@ void QgsValueMapWidgetWrapper::updateValues( const QVariant &value, const QVaria
{ {
if ( mComboBox->findData( v ) == -1 && !( v.startsWith( '(' ) && v.endsWith( ')' ) ) ) if ( mComboBox->findData( v ) == -1 && !( v.startsWith( '(' ) && v.endsWith( ')' ) ) )
{ {
mComboBox->addItem( v.prepend( '(' ).append( ')' ), v ); if ( value.isNull( ) )
{
mComboBox->addItem( QgsApplication::nullRepresentation().prepend( '(' ).append( ')' ), v );
}
else
{
mComboBox->addItem( v.prepend( '(' ).append( ')' ), v );
}
} }
mComboBox->setCurrentIndex( mComboBox->findData( v ) ); mComboBox->setCurrentIndex( mComboBox->findData( v ) );
} }
Expand Down

0 comments on commit bc0f478

Please sign in to comment.