Skip to content

Commit

Permalink
Merge pull request #5917 from johnhaddon/colorChooseSignalling
Browse files Browse the repository at this point in the history
ColorChooser : Don't emit signals with inconsistent internal state
  • Loading branch information
ericmehl authored Jun 24, 2024
2 parents bd50769 + 1df32d4 commit 21c0581
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Fixes
- Cycles : Fixed rendering to the Catalogue using the batch Render node (#5905). Note that rendering a mixture of Catalogue and file outputs is still not supported, and in this case any file outputs will be ignored.
- CodeWidget : Fixed bug that could prevent changes from being committed while the completion menu was visible.
- Loop : Fixed handling of empty `indexVariable`. This now disables the Loop instead of creating an unnamed context variable.
- ColorChooser : Fixed emission of `colorChangedSignal()` while the widget was in an inconsistent internal state.

API
---
Expand Down
12 changes: 7 additions & 5 deletions python/GafferUI/ColorChooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,12 @@ def __setColorInternal( self, color, reason, hsv = False ) :
GafferUI.NumericWidget.ValueChangedReason.DragEnd,
)

previousColor = self.__colorHSV if hsv else self.__color
colorChanged = color != ( self.__colorHSV if hsv else self.__color )

if color != previousColor or dragBeginOrEnd :
# we never optimise away drag begin or end, because it's important
# that they emit in pairs.
if colorChanged :
colorRGB = color.hsv2rgb() if hsv else color
self.__color = colorRGB
self.__colorSwatch.setColor( colorRGB )
self.__colorChangedSignal( self, reason )

hsv = color if hsv else color.rgb2hsv()

Expand All @@ -281,6 +278,11 @@ def __setColorInternal( self, color, reason, hsv = False ) :
# in NumericWidget.
self.__updateUIFromColor()

if colorChanged or dragBeginOrEnd :
# We never optimise away drag begin or end, because it's important
# that they emit in pairs.
self.__colorChangedSignal( self, reason )

def __updateUIFromColor( self ) :

with Gaffer.Signals.BlockedConnection( self.__componentValueChangedConnections ) :
Expand Down

0 comments on commit 21c0581

Please sign in to comment.