Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ColorChooser : Don't emit signals with inconsistent internal state #5917

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 :
ericmehl marked this conversation as resolved.
Show resolved Hide resolved
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
Loading