spek

Acoustic spectrum analyser
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

commit acb3097f4b0ff78d861db8e0c036f75749a448f5
parent 71a8cccb4b7c8ad33b2c7b998716d03839f331b6
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Sun, 16 May 2010 21:26:28 +1000

Fix a crash when the window is very small

Diffstat:
Msrc/spek-ruler.vala | 2+-
Msrc/spek-spectrogram.vala | 18+++++++++++-------
2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/spek-ruler.vala b/src/spek-ruler.vala @@ -1,4 +1,4 @@ -/* spek-spectrogram.vala +/* spek-ruler.vala * * Copyright (C) 2010 Alexander Kojevnikov <alexander@kojevnikov.com> * diff --git a/src/spek-spectrogram.vala b/src/spek-spectrogram.vala @@ -58,17 +58,21 @@ namespace Spek { } private void start () { + if (this.source != null) { + this.source.stop (); + } + // The number of samples is the number of pixels available for the image. // The number of bands is fixed, FFT results are very different for // different values but we need some consistency. - this.image = new ImageSurface (Format.RGB24, allocation.width - 2 * PADDING, BANDS); - - if (this.source != null) { - this.source.stop (); + int samples = allocation.width - 2 * PADDING; + if (samples > 0) { + image = new ImageSurface (Format.RGB24, samples, BANDS); + source = new Source (file_name, BANDS, samples, THRESHOLD, source_callback); + } else { + image = null; + source = null; } - this.source = new Source ( - file_name, image.get_height (), image.get_width (), - THRESHOLD, source_callback); queue_draw (); }