For now (after a quick test) it seems that my approach works fine.
template <class T> void performOrWaitAllRequestsDone (T f) const
{
if (spaghettis::Spaghettis()->isAllRequestsDone()) { f(); }
else {
juce::Timer::callAfterDelay (500.0, [this, f = f]() { performOrWaitAllRequestsDone<T> (f); });
}
}
void systemRequestedQuit() override
{
performOrWaitAllRequestsDone ([]() { DBG ("!"); });
spaghettis::Spaghettis()->closeAllPatches();
performOrWaitAllRequestsDone ([]() { quit(); });
}
See also: