Fix attempt for X11 runloop problems #986
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.