Fix wait for thread not started

This commit is contained in:
Samuele Panzeri 2023-04-27 18:34:30 +02:00
parent 240ed28291
commit 4aaa2e6477
16 changed files with 45 additions and 18 deletions

View File

@ -339,7 +339,9 @@ void AudioDriverALSA::finish_output_device() {
void AudioDriverALSA::finish() { void AudioDriverALSA::finish() {
exit_thread.set(); exit_thread.set();
thread.wait_to_finish(); if (thread.is_started()) {
thread.wait_to_finish();
}
finish_output_device(); finish_output_device();
} }

View File

@ -207,7 +207,9 @@ Error MIDIDriverALSAMidi::open() {
void MIDIDriverALSAMidi::close() { void MIDIDriverALSAMidi::close() {
exit_thread.set(); exit_thread.set();
thread.wait_to_finish(); if (thread.is_started()) {
thread.wait_to_finish();
}
for (int i = 0; i < connected_inputs.size(); i++) { for (int i = 0; i < connected_inputs.size(); i++) {
snd_rawmidi_t *midi_in = connected_inputs[i].rawmidi_ptr; snd_rawmidi_t *midi_in = connected_inputs[i].rawmidi_ptr;

View File

@ -676,7 +676,9 @@ void AudioDriverPulseAudio::finish() {
} }
exit_thread.set(); exit_thread.set();
thread.wait_to_finish(); if (thread.is_started()) {
thread.wait_to_finish();
}
finish_output_device(); finish_output_device();

View File

@ -930,7 +930,9 @@ void AudioDriverWASAPI::unlock() {
void AudioDriverWASAPI::finish() { void AudioDriverWASAPI::finish() {
exit_thread.set(); exit_thread.set();
thread.wait_to_finish(); if (thread.is_started()) {
thread.wait_to_finish();
}
finish_input_device(); finish_input_device();
finish_output_device(); finish_output_device();

View File

@ -151,7 +151,9 @@ void AudioDriverXAudio2::unlock() {
void AudioDriverXAudio2::finish() { void AudioDriverXAudio2::finish() {
exit_thread.set(); exit_thread.set();
thread.wait_to_finish(); if (thread.is_started()) {
thread.wait_to_finish();
}
if (source_voice) { if (source_voice) {
source_voice->Stop(0); source_voice->Stop(0);

View File

@ -1256,7 +1256,9 @@ void EditorFileSystem::_notification(int p_what) {
if (scanning_changes_done) { if (scanning_changes_done) {
set_process(false); set_process(false);
thread_sources.wait_to_finish(); if (thread_sources.is_started()) {
thread_sources.wait_to_finish();
}
bool changed = _update_scan_actions(); bool changed = _update_scan_actions();
_update_pending_script_classes(); _update_pending_script_classes();
if (changed) { if (changed) {

View File

@ -2371,9 +2371,6 @@ void EditorHelp::update_doc() {
void EditorHelp::cleanup_doc() { void EditorHelp::cleanup_doc() {
_wait_for_thread(); _wait_for_thread();
if (doc_gen_use_threads) {
thread.wait_to_finish();
}
memdelete(doc); memdelete(doc);
} }

View File

@ -44,7 +44,9 @@ NoiseTexture2D::~NoiseTexture2D() {
if (texture.is_valid()) { if (texture.is_valid()) {
RS::get_singleton()->free(texture); RS::get_singleton()->free(texture);
} }
noise_thread.wait_to_finish(); if (noise_thread.is_started()) {
noise_thread.wait_to_finish();
}
} }
void NoiseTexture2D::_bind_methods() { void NoiseTexture2D::_bind_methods() {

View File

@ -604,7 +604,9 @@ RaycastOcclusionCull::~RaycastOcclusionCull() {
for (KeyValue<RID, Scenario> &K : scenarios) { for (KeyValue<RID, Scenario> &K : scenarios) {
Scenario &scenario = K.value; Scenario &scenario = K.value;
if (scenario.commit_thread) { if (scenario.commit_thread) {
scenario.commit_thread->wait_to_finish(); if (scenario.commit_thread->is_started()) {
scenario.commit_thread->wait_to_finish();
}
memdelete(scenario.commit_thread); memdelete(scenario.commit_thread);
} }

View File

@ -1984,6 +1984,8 @@ EditorExportPlatformIOS::EditorExportPlatformIOS() {
EditorExportPlatformIOS::~EditorExportPlatformIOS() { EditorExportPlatformIOS::~EditorExportPlatformIOS() {
#ifndef ANDROID_ENABLED #ifndef ANDROID_ENABLED
quit_request.set(); quit_request.set();
check_for_changes_thread.wait_to_finish(); if (check_for_changes_thread.is_started()) {
check_for_changes_thread.wait_to_finish();
}
#endif #endif
} }

View File

@ -687,5 +687,7 @@ EditorExportPlatformWeb::~EditorExportPlatformWeb() {
server->stop(); server->stop();
} }
server_quit = true; server_quit = true;
server_thread.wait_to_finish(); if (server_thread.is_started()) {
server_thread.wait_to_finish();
}
} }

View File

@ -270,7 +270,9 @@ void NavigationRegion3D::bake_navigation_mesh(bool p_on_thread) {
void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_nav_mesh) { void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_nav_mesh) {
set_navigation_mesh(p_nav_mesh); set_navigation_mesh(p_nav_mesh);
bake_thread.wait_to_finish(); if (bake_thread.is_started()) {
bake_thread.wait_to_finish();
}
emit_signal(SNAME("bake_finished")); emit_signal(SNAME("bake_finished"));
} }

View File

@ -190,7 +190,9 @@ void HTTPRequest::cancel_request() {
set_process_internal(false); set_process_internal(false);
} else { } else {
thread_request_quit.set(); thread_request_quit.set();
thread.wait_to_finish(); if (thread.is_started()) {
thread.wait_to_finish();
}
} }
file.unref(); file.unref();

View File

@ -136,7 +136,9 @@ void AudioDriverDummy::mix_audio(int p_frames, int32_t *p_buffer) {
void AudioDriverDummy::finish() { void AudioDriverDummy::finish() {
if (use_threads) { if (use_threads) {
exit_thread.set(); exit_thread.set();
thread.wait_to_finish(); if (thread.is_started()) {
thread.wait_to_finish();
}
} }
if (samples_in) { if (samples_in) {

View File

@ -120,7 +120,9 @@ void AudioEffectRecordInstance::init() {
} }
void AudioEffectRecordInstance::finish() { void AudioEffectRecordInstance::finish() {
io_thread.wait_to_finish(); if (io_thread.is_started()) {
io_thread.wait_to_finish();
}
} }
AudioEffectRecordInstance::~AudioEffectRecordInstance() { AudioEffectRecordInstance::~AudioEffectRecordInstance() {

View File

@ -237,7 +237,9 @@ void RenderingServerDefault::init() {
void RenderingServerDefault::finish() { void RenderingServerDefault::finish() {
if (create_thread) { if (create_thread) {
command_queue.push(this, &RenderingServerDefault::_thread_exit); command_queue.push(this, &RenderingServerDefault::_thread_exit);
thread.wait_to_finish(); if (thread.is_started()) {
thread.wait_to_finish();
}
} else { } else {
_finish(); _finish();
} }