1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Fix crash in AudioStream preview

This commit is contained in:
RedworkDE
2023-05-30 16:49:58 +02:00
parent 8f25cc2d13
commit 301731c7e6
2 changed files with 9 additions and 7 deletions

View File

@@ -75,7 +75,8 @@ void AudioStreamEditor::_notification(int p_what) {
void AudioStreamEditor::_draw_preview() {
Size2 size = get_size();
if ((int)size.width <= 0) {
int width = size.width;
if (width <= 0) {
return; // No points to draw.
}
@@ -85,9 +86,9 @@ void AudioStreamEditor::_draw_preview() {
float preview_len = preview->get_length();
Vector<Vector2> points;
points.resize((int)size.width * 2);
points.resize(width * 2);
for (int i = 0; i < size.width; i++) {
for (int i = 0; i < width; i++) {
float ofs = i * preview_len / size.width;
float ofs_n = (i + 1) * preview_len / size.width;
float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5;