diff options
Diffstat (limited to 'editor/audio_stream_preview.cpp')
-rw-r--r-- | editor/audio_stream_preview.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index 81a6f78415..f8bf12227a 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -214,25 +214,27 @@ void AudioStreamPreviewGenerator::_bind_methods() { AudioStreamPreviewGenerator *AudioStreamPreviewGenerator::singleton = nullptr; void AudioStreamPreviewGenerator::_notification(int p_what) { - if (p_what == NOTIFICATION_PROCESS) { - List<ObjectID> to_erase; - for (KeyValue<ObjectID, Preview> &E : previews) { - if (!E.value.generating.is_set()) { - if (E.value.thread) { - E.value.thread->wait_to_finish(); - memdelete(E.value.thread); - E.value.thread = nullptr; - } - if (!ObjectDB::get_instance(E.key)) { //no longer in use, get rid of preview - to_erase.push_back(E.key); + switch (p_what) { + case NOTIFICATION_PROCESS: { + List<ObjectID> to_erase; + for (KeyValue<ObjectID, Preview> &E : previews) { + if (!E.value.generating.is_set()) { + if (E.value.thread) { + E.value.thread->wait_to_finish(); + memdelete(E.value.thread); + E.value.thread = nullptr; + } + if (!ObjectDB::get_instance(E.key)) { //no longer in use, get rid of preview + to_erase.push_back(E.key); + } } } - } - while (to_erase.front()) { - previews.erase(to_erase.front()->get()); - to_erase.pop_front(); - } + while (to_erase.front()) { + previews.erase(to_erase.front()->get()); + to_erase.pop_front(); + } + } break; } } |