renderer: implemented function to wait for workers in the main thread

The workers run in separate threads meaning if any significant change is made
(e.g. parameters changing, or even closing the program), these workers may still
be mid-render. This is particularly problematic when closing since the nodes a
worker is rendering may be deleted mid-render. Render backends now have a
function that pauses the main thread (but starts a second event loop so the UI
isn't frozen) until the worker threads are all finished. This way, massive
changes can be made safely without race conditions.
This commit is contained in:
itsmattkc
2020-01-22 17:11:17 +11:00
parent fdbaa75dff
commit 24f7eeb210
11 changed files with 197 additions and 20 deletions
@@ -105,12 +105,15 @@ void PreferencesAudioTab::Accept()
// FIXME: Qt documentation states that QAudioDeviceInfo::deviceName() is a "unique identifiers", which would make them
// ideal for saving in preferences, but in practice they don't actually appear to be unique.
// See: https://bugreports.qt.io/browse/QTBUG-16841
Config::Current()["AudioOutput"] = selected_output_name;
Config::Current()["AudioInput"] = selected_input_name;
if (Config::Current()["AudioOutput"] != selected_output_name) {
Config::Current()["AudioOutput"] = selected_output_name;
AudioManager::instance()->SetOutputDevice(selected_output);
}
// Finally, set these as the current device
AudioManager::instance()->SetOutputDevice(selected_output);
AudioManager::instance()->SetInputDevice(selected_input);
if (Config::Current()["AudioInput"] != selected_input_name) {
Config::Current()["AudioInput"] = selected_input_name;
AudioManager::instance()->SetInputDevice(selected_input);
}
}
void PreferencesAudioTab::RefreshDevices()