Skip to content

Commit 94d88e6

Browse files
committed
Correctly return null values from QgsColorWidgetWrapper
1 parent 58e1c7f commit 94d88e6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/gui/editorwidgets/qgscolorwidgetwrapper.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ QgsColorWidgetWrapper::QgsColorWidgetWrapper( QgsVectorLayer* vl, int fieldIdx,
2525

2626
QVariant QgsColorWidgetWrapper::value() const
2727
{
28-
QVariant v;
29-
28+
QColor c;
3029
if ( mColorButton )
31-
v = mColorButton->color();
30+
c = mColorButton->color();
3231

33-
return v;
32+
return c.isValid() ? QVariant( c ) : QVariant( QVariant::Color );
3433
}
3534

3635
void QgsColorWidgetWrapper::showIndeterminateState()
@@ -76,5 +75,5 @@ bool QgsColorWidgetWrapper::valid() const
7675
void QgsColorWidgetWrapper::setValue( const QVariant& value )
7776
{
7877
if ( mColorButton )
79-
mColorButton->setColor( QColor( value.toString() ) );
78+
mColorButton->setColor( !value.isNull() ? QColor( value.toString() ) : QColor() );
8079
}

0 commit comments

Comments
 (0)