[Ardour-Dev] ARDOUR::AutomationList and the StateChanged signal
John Emmas
johne53 at tiscali.co.uk
Sat Apr 24 02:19:00 PDT 2010
Hi Paul. I eventually found the problem. 'AudioRegion::_fade_in' wasn't
going out of scope but its 'events' list was becoming temporarily
invalidated. The crash was happening because in function
AudioRegion::reset_fade_in_shape(), this call was being made:-
reset_fade_in_shape_width ((nframes_t)
audio_region()->fade_in().back()->when);
when 'audio_region()->fade_in()' has no elements. Here's some code that
will illustrate the problem:-
void
AudioRegionView::reset_fade_in_shape ()
{
#if 1 // JE - For testing !!!
Curve& fadein = audio_region()->fade_in();
if (fadein.empty())
cout << "NO FADE_IN ELEMENTS - CRASH SHOULD BE IMMINENT !!" << endl;
else
{
size_t fs = fadein.size();
cout << "Detected " << fs << " fade_in events" << endl;
}
// And this is the line that should crash if '_fade_in' has no elements
reset_fade_in_shape_width ((nframes_t) fadein.back()->when);
#else
// This is the original code
reset_fade_in_shape_width ((nframes_t)
audio_region()->fade_in().back()->when);
#endif
}
The line after #else is the original code. The lines above it are the same
code, broken down into steps and tested. Run Ardour from the command
line and load a very simple session (say with just one timeline region).
You'll probably notice that its fade_in contains two events. Now drag the
region slightly and try to undo the drag. You should see that
'AudioRegionView::reset_fade_in_shape()' is getting called twice when the
fade_in has zero elements. For some reason (probably luck) this doesn't
seem to cause any problems for gcc but it crashes when compiled using VC++.
I'm guessing that this would offer the simplest solution:-
void
AudioRegionView::reset_fade_in_shape ()
{
if ( ! audio_region()->fade_in().empty() )
reset_fade_in_shape_width ((nframes_t)
audio_region()->fade_in().back()->when);
}
Hopefully without any side-effects?
John
More information about the Ardour-Dev
mailing list