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

Handle unordered add / position change events #1555

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions source/frontend/patchcanvas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ def __init__(self):
self.initial_pos = QPointF(0, 0)
self.size_rect = QRectF()

self.pending_group_joins = set()
self.pending_position_changes = {}

def callback(self, action, value1, value2, value_str):
print("Canvas::callback({}, {}, {}, {})".format(action, value1, value2, value_str))

Expand Down
13 changes: 13 additions & 0 deletions source/frontend/patchcanvas/patchcanvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,17 @@ def addGroup(group_id, group_name, split=SPLIT_UNDEF, icon=ICON_APPLICATION):

canvas.group_list.append(group_dict)

# Callbacks can arrive out of order, so we might have pending events.
if group_id in canvas.pending_group_joins:
joinGroup(group_id)
canvas.pending_group_joins.remove(group_id)

if group_id in canvas.pending_position_changes:
position_change = canvas.pending_position_changes[group_id]
setGroupPosFull(*position_change)
del canvas.pending_position_changes[group_id]


if options.eyecandy == EYECANDY_FULL and not options.auto_hide_groups:
CanvasItemFX(group_box, True, False)
else:
Expand Down Expand Up @@ -602,6 +613,7 @@ def joinGroup(group_id):
# FIXME
if not (item and s_item):
qCritical("PatchCanvas::joinGroup(%i) - unable to find groups to join" % group_id)
canvas.pending_group_joins.add(group_id)
return

port_list_ids = list(item.getPortList())
Expand Down Expand Up @@ -755,6 +767,7 @@ def setGroupPosFull(group_id, group_pos_x_o, group_pos_y_o, group_pos_x_i, group

qCritical("PatchCanvas::setGroupPos(%i, %i, %i, %i, %i) - unable to find group to reposition" % (
group_id, group_pos_x_o, group_pos_y_o, group_pos_x_i, group_pos_y_i))
canvas.pending_position_changes[group_id] = (group_id, group_pos_x_o, group_pos_y_o, group_pos_x_i, group_pos_y_i)

# ------------------------------------------------------------------------------------------------------------

Expand Down