Fix a crash when the window is very small

This commit is contained in:
Alexander Kojevnikov 2010-05-16 21:26:28 +10:00
parent 71a8cccb4b
commit acb3097f4b
2 changed files with 13 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* spek-spectrogram.vala
/* spek-ruler.vala
*
* Copyright (C) 2010 Alexander Kojevnikov <alexander@kojevnikov.com>
*

View File

@ -58,17 +58,21 @@ namespace Spek {
}
private void start () {
// 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 ();
}
this.source = new Source (
file_name, image.get_height (), image.get_width (),
THRESHOLD, source_callback);
// 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.
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;
}
queue_draw ();
}