Closed kunalarya closed 1 year ago
I am not really a fan of heuristic solutions like this. As you say, in situations like in Reaper where the NSWindow
outlives Baseview's NSView
, this notification won't occur; and, in the reverse situation, where the host closes the containing NSWindow
but retains a reference to Baseview's NSView
and then reparents it to another window, this notification will result in premature destruction of the Baseview window.
There was a discussion on the Rust Audio Discord several months ago about changing Baseview's API contract so that windows may only be closed via an explicit call to WindowHandle::close()
or Window::close()
, which would resolve the refcount cycle issue in a more principled way. I'll write that up in more detail on #124.
In order to use third party crates that, under the hood, may increase the ref count of the given
NSView
, we add an additional "window closing" check by querying the givenNSView
for itsNSWindow
parent, and subscribing to theNSWindowWillCloseNotification
message.Note that in DAWs such as Reaper, we share a parent window with other plugins, so this approach is not reliable (since you can switch between different plugins but the window persists). Those cases may require another solution.
(Mostly) fixes #124