Skip to content

Commit 41a98ca

Browse files
committed
Correctly return null values from QgsColorWidgetWrapper
(cherry-picked from 94d88e6)
1 parent 0234cd2 commit 41a98ca

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
@@ -24,12 +24,11 @@ QgsColorWidgetWrapper::QgsColorWidgetWrapper( QgsVectorLayer* vl, int fieldIdx,
2424

2525
QVariant QgsColorWidgetWrapper::value() const
2626
{
27-
QVariant v;
28-
27+
QColor c;
2928
if ( mColorButton )
30-
v = mColorButton->color();
29+
c = mColorButton->color();
3130

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

3534
QWidget* QgsColorWidgetWrapper::createWidget( QWidget* parent )
@@ -54,5 +53,5 @@ bool QgsColorWidgetWrapper::valid() const
5453
void QgsColorWidgetWrapper::setValue( const QVariant& value )
5554
{
5655
if ( mColorButton )
57-
mColorButton->setColor( QColor( value.toString() ) );
56+
mColorButton->setColor( !value.isNull() ? QColor( value.toString() ) : QColor() );
5857
}

0 commit comments

Comments
 (0)