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

Conversation

StefansM
Copy link
Contributor

Fixes (some cases of) plugins ignoring saved (x, y) coordinates when a
project is loaded. The canvas can get notified of a plugin's position
before the plugin is actually added, so when the plugin is actually it
just goes to the default position.

This happens because PatchbayClientPositionChanged events can arrive
before PatchbayClientAdded events, as seen in debug logs like this:

...
PatchCanvas::joinGroup(30)
PatchCanvas::joinGroup(30) - unable to find groups to join
PatchCanvas::setGroupPos(30, 1118, 591, 0, 0)
PatchCanvas::setGroupPos(30, 1118, 591, 0, 0) - unable to find group to reposition
PatchCanvas::addGroup(30, b'Audio to CV', SPLIT_UNDEF, ICON_PLUGIN)
...

If this happens, the canvas box will be placed in the default position,
rather than obeying the PatchbayClientPositionChanged signal. This PR
keeps track of missed events and then applies them once the object is
actually added.

Fixes (some cases of) plugins ignoring saved `(x, y)` coordinates when a
project is loaded. The canvas can get notified of a plugin's position
before the plugin is actually added, so when the plugin is actually it
just goes to the default position.

This happens because `PatchbayClientPositionChanged` events can arrive
before `PatchbayClientAdded` events, as seen in debug logs like this:

```
...
PatchCanvas::joinGroup(30)
PatchCanvas::joinGroup(30) - unable to find groups to join
PatchCanvas::setGroupPos(30, 1118, 591, 0, 0)
PatchCanvas::setGroupPos(30, 1118, 591, 0, 0) - unable to find group to reposition
PatchCanvas::addGroup(30, b'Audio to CV', SPLIT_UNDEF, ICON_PLUGIN)
...
```

If this happens, the canvas box will be placed in the default position,
rather than obeying the `PatchbayClientPositionChanged` signal. This PR
keeps track of missed events and then applies them once the object is
actually added.
@StefansM
Copy link
Contributor Author

I'm sure that there is a better way to do this, but some quick googling suggests that QT doesn't guarantee the order in which slots get called, so state will need to be aggregated somewhere.

@falkTX
Copy link
Owner

falkTX commented Jan 2, 2022

is this happening using pipewire or jack?

@StefansM
Copy link
Contributor Author

Apologies for the slow response. I've only observed this using Jack. I've not tried with any other backends though, so I can't draw any conclusions from that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants