From: Andrew Soknacki Date: Fri, 9 Oct 2015 17:47:11 +0000 (-0400) Subject: Fix a bug with color picking. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4452730c1cdac699ac7edfe98821a68ab0d1a701;p=sigrok-meter.git Fix a bug with color picking. Previously, the QColorDialog, returned a invalid QColor if the dialog was canceled. --- diff --git a/datamodel.py b/datamodel.py index 2b29fa4..d54f429 100644 --- a/datamodel.py +++ b/datamodel.py @@ -226,9 +226,11 @@ class MultimeterDelegate(QtGui.QStyledItemDelegate): c = index.data(MeasurementDataModel.colorRole) c = QtGui.QColorDialog.getColor(c, None, 'Choose new color for channel') - - item = model.itemFromIndex(index) - item.setData(c, MeasurementDataModel.colorRole) + if c.isValid(): + # False if cancel is pressed (resulting in a black + # color) + item = model.itemFromIndex(index) + item.setData(c, MeasurementDataModel.colorRole) return True