Bug 1226 - Plot Spectrum freezes first time in a project if insufficient samples selected

Guarding against mDataLen < mWindowSize, as per fix from Steve.
However, also must ensure mAnalyst was initialised, as we otherwise get a different crash when we paint a valid spectrum later, because we don't init mAnalyst when too few samples.  To do that init, we must call Recalc before we show the dialog.

Needs to be tested on Mac, because the change from SendRecalcEvent() to Recalc() might conceivably upset the Mac.
This commit is contained in:
James Crook 2015-10-06 21:28:22 +01:00
parent 48c5c47214
commit ae5d29a048
1 changed files with 8 additions and 4 deletions

View File

@ -532,17 +532,20 @@ bool FreqWindow::Show(bool show)
bool shown = IsShown();
bool res = wxDialog::Show(show);
if (show && !shown)
{
gPrefs->Read(ENV_DB_KEY, &dBRange, ENV_DB_RANGE);
if(dBRange < 90.)
dBRange = 90.;
GetAudio();
SendRecalcEvent();
// Don't send an event. We need the recalc right away.
// so that mAnalyst is valid when we paint.
//SendRecalcEvent();
Recalc();
}
bool res = wxDialog::Show(show);
return res;
}
@ -859,7 +862,8 @@ void FreqWindow::PlotPaint(wxPaintEvent & event)
wxPaintDC dc( (wxWindow *) event.GetEventObject() );
dc.DrawBitmap( *mBitmap, 0, 0, true );
if (!mData)
// Fix for Bug 1226 "Plot Spectrum freezes... if insufficient samples selected"
if (!mData || mDataLen < mWindowSize)
return;
dc.SetFont(mFreqFont);