Skip to content

Commit

Permalink
Make sure empty array in listwidget is null
Browse files Browse the repository at this point in the history
Fixes #38176

(cherry picked from commit 5c225cc)
  • Loading branch information
stev-0 authored and nyalldawson committed Jan 15, 2021
1 parent 9d7bdea commit b21b863
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/gui/editorwidgets/qgslistwidgetwrapper.cpp
Expand Up @@ -70,16 +70,25 @@ QVariant QgsListWidgetWrapper::value() const
{
QVariant::Type type = field().type();
if ( !mWidget ) return QVariant( type );
const QVariantList list = mWidget->list();
if ( type == QVariant::StringList )
{
QStringList result;
const QVariantList list = mWidget->list();
for ( QVariantList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
result.append( it->toString() );
return result;
}
else
return QVariant( mWidget->list() );
{
if ( list.size() == 0 )
{
return QVariant( );
}
else
{
return list;
}
}
}

void QgsListWidgetWrapper::onValueChanged()
Expand Down

0 comments on commit b21b863

Please sign in to comment.