You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Port existing _notification code to use switch statements (part 1/3)
This commit is contained in:
committed by
Jean-Michel Bernard
parent
f5b9cbaff6
commit
dcd2a92af3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user