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

Fix attempt for X11 runloop problems #986

Merged
merged 2 commits into from
Sep 20, 2021
Merged

Conversation

jpcima
Copy link
Collaborator

@jpcima jpcima commented Sep 20, 2021

This is a rewrite of the VST-X11 runloop system.
It's excepted to at least fix the current Reaper crashes, I don't know yet of possible regressions.

This is the big picture:
VSTGUI needs a runloop interface implemented, which allows it to register its event/timer handlers to the window system.
Somewhat conveniently, the VST3 host presents a matching interface, so one only needs to glue the 2 together.

To do the glue, each of the VSTGUI handler callback is wrapped into a VST3 object, that is then attached to VST3 by the interface provided.
One must keep track of all these wrapper objects, so we keep them in a vector.
Extra care is taken to stabilize the vector traversals, because additions and removals of handlers can happen inside a handler callback. The new strategy is to let the unused vector slots be zombie objects, with alive boolean as a marker, where indices never vary and the vector never shrinks, but the zombie slots get reused.

In addition:

  • if a vstgui timer is removed when vstgui has no global RunLoop assigned (all CFrames deleted), the timer removal fails.
    Next time a runloop will run, the destroyed timer which has remained registered will crash it.
    The solution is to make sure to recreate/delete the editor on VST's open/close. GIven that we're now on the better update model, this must not be a problem.
  • added a debug function to know what's in the runloop, in case it's needed to debug it again
  • there will be error output if a handler is called without active runloop. this should never happen.
  • there's disabled code in the RunLoop destructor, to eliminate the leftover handlers. it's not necessary if the host does its job, but it's left in case it might turn out useful.

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.

1 participant