]> sigrok.org Git - sigrok-meter.git/commitdiff
Fix a bug with color picking.
authorAndrew Soknacki <redacted>
Fri, 9 Oct 2015 17:47:11 +0000 (13:47 -0400)
committerAndrew Soknacki <redacted>
Tue, 13 Oct 2015 17:18:35 +0000 (13:18 -0400)
Previously, the QColorDialog, returned a invalid QColor if the dialog was
canceled.

datamodel.py

index 2b29fa4b3db328c6d398f63a533c8e7989c7f9b9..d54f42968273edc0a4d27aaad3faf5eaf9e650c8 100644 (file)
@@ -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