Skip to content

Commit

Permalink
Only update Maya selection when the Solver UI window has active focus.
Browse files Browse the repository at this point in the history
Removed temp fix for the same problem by using evalDeferred to update selection.
  • Loading branch information
david-cattermole committed Jun 25, 2020
1 parent 8eea80e commit 920f0b4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
15 changes: 4 additions & 11 deletions python/mmSolver/tools/solver/maya_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,15 +550,8 @@ def selection_changed_func(clientData):
"""
if mmapi.is_solver_running() is True:
return

def func():
if mmapi.is_solver_running() is True:
return
sel_uuids = maya.cmds.ls(selection=True, uuid=True) or []
valid = uiutils.isValidQtObject(clientData)
if clientData is not None and valid is True:
clientData.setNodeSelection(sel_uuids)
return

maya.cmds.evalDeferred(func, lowestPriority=True)
sel_uuids = maya.cmds.ls(selection=True, uuid=True) or []
valid = uiutils.isValidQtObject(clientData)
if clientData is not None and valid is True:
clientData.setNodeSelection(sel_uuids)
return
25 changes: 15 additions & 10 deletions python/mmSolver/tools/solver/widget/attribute_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,21 @@ def selectionChanged(self, selected, deselected):
selected_nodes = _lookupMayaNodesFromAttrUINodes(
selected_indexes,
self.filterModel)
# Because an attribute and node may refer to the same
# underlying node name, we must be sure we don't deselect a
# node that has other attributes selected.
deselect_nodes = list(set(deselect_nodes) - set(selected_nodes))
try:
mmapi.set_solver_running(True) # disable selection callback.
lib_maya_utils.add_scene_selection(select_nodes)
lib_maya_utils.remove_scene_selection(deselect_nodes)
finally:
mmapi.set_solver_running(False) # enable selection callback
if self.isActiveWindow() is True:
# Only allow Maya selection changes when the user has the
# UI focused. This breaks the Maya and Qt selection
# callback cycle.

# Because an attribute and node may refer to the same
# underlying node name, we must be sure we don't deselect a
# node that has other attributes selected.
deselect_nodes = list(set(deselect_nodes) - set(selected_nodes))
try:
mmapi.set_solver_running(True) # disable selection callback.
lib_maya_utils.add_scene_selection(select_nodes)
lib_maya_utils.remove_scene_selection(deselect_nodes)
finally:
mmapi.set_solver_running(False) # enable selection callback
return

@QtCore.Slot(bool)
Expand Down
16 changes: 10 additions & 6 deletions python/mmSolver/tools/solver/widget/object_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,16 @@ def selectionChanged(self, selected, deselected):
deselect_indexes,
self.filterModel
)
try:
mmapi.set_solver_running(True) # disable selection callback.
lib_maya_utils.add_scene_selection(select_nodes)
lib_maya_utils.remove_scene_selection(deselect_nodes)
finally:
mmapi.set_solver_running(False) # enable selection callback
if self.isActiveWindow() is True:
# Only allow Maya selection changes when the user has the
# UI focused. This breaks the Maya and Qt selection
# callback cycle.
try:
mmapi.set_solver_running(True) # disable selection callback.
lib_maya_utils.add_scene_selection(select_nodes)
lib_maya_utils.remove_scene_selection(deselect_nodes)
finally:
mmapi.set_solver_running(False) # enable selection callback
return

@QtCore.Slot(bool)
Expand Down

0 comments on commit 920f0b4

Please sign in to comment.