GoldenCheetah/GoldenCheetah — pull request #856 by ibooij (2014-04-21 20:22:07+00:00)
Title: Fix crash when opening Speed histogram for the first time, on a file without speed info.

I had a trainer file as the second file in my history. Opening this ride, and selecting the speed histogram made GC crash.

I narrowed it down to line 905 in src/PowerHist.cpp. The code was trying to do a resize on a QVector with a negative value. count was -7.

int count = int(ceil((arrayLength - 1) / (binw)))+1;
// allocate space for data, plus beginning and ending point
x.resize(count+2);

Making sure that count is always 0 or greater fixed the crash.

Note that opening another ride file, with speed information before this one, selecting the speed histogram and only after that selecting the ride without speed information, did not crash the application. I'm suspecting that there might be some resetting of values, perhaps in the "standards" arrays, that is not done when a data series is missing.

BTW, the trainer file was recorded on a Garmin Edge 800. I had power, cadence and heart rate, but no speed, given I was our shed.

cheers,
Ilja