mirror of
https://github.com/godotengine/godot
synced 2024-09-16 02:17:12 +00:00
Fix editor crash on audio preview
- Crash was due to getting -1 values when clamping [0, -1]. - This was happening due to 'max' being zero. - If 'max' is zero we should return zero, as it can never be any other value.
This commit is contained in:
parent
b05e1e7d69
commit
9a666a9275
|
@ -42,6 +42,10 @@ float AudioStreamPreview::get_max(float p_time, float p_time_next) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int max = preview.size() / 2;
|
int max = preview.size() / 2;
|
||||||
|
if (max == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int time_from = p_time / length * max;
|
int time_from = p_time / length * max;
|
||||||
int time_to = p_time_next / length * max;
|
int time_to = p_time_next / length * max;
|
||||||
time_from = CLAMP(time_from, 0, max - 1);
|
time_from = CLAMP(time_from, 0, max - 1);
|
||||||
|
@ -69,6 +73,10 @@ float AudioStreamPreview::get_min(float p_time, float p_time_next) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int max = preview.size() / 2;
|
int max = preview.size() / 2;
|
||||||
|
if (max == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int time_from = p_time / length * max;
|
int time_from = p_time / length * max;
|
||||||
int time_to = p_time_next / length * max;
|
int time_to = p_time_next / length * max;
|
||||||
time_from = CLAMP(time_from, 0, max - 1);
|
time_from = CLAMP(time_from, 0, max - 1);
|
||||||
|
|
Loading…
Reference in a new issue