Only create a Curve for an AutomationList if we need it.

Fix crash on crossfade editor show (ticket 2442).


git-svn-id: svn://localhost/ardour2/branches/3.0@4641 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2009-02-19 19:42:25 +00:00
parent c006ff1762
commit 75c15679bf
13 changed files with 69 additions and 19 deletions

View file

@ -33,6 +33,8 @@
#include <pbd/memento_command.h> #include <pbd/memento_command.h>
#include <pbd/stacktrace.h> #include <pbd/stacktrace.h>
#include <evoral/Curve.hpp>
#include "streamview.h" #include "streamview.h"
#include "audio_region_view.h" #include "audio_region_view.h"
#include "audio_time_axis.h" #include "audio_time_axis.h"

View file

@ -66,10 +66,9 @@ CrossfadeEditor::Presets* CrossfadeEditor::fade_in_presets = 0;
CrossfadeEditor::Presets* CrossfadeEditor::fade_out_presets = 0; CrossfadeEditor::Presets* CrossfadeEditor::fade_out_presets = 0;
CrossfadeEditor::Half::Half () CrossfadeEditor::Half::Half ()
: line (0), : line (0)
//normative_curve (Evoral::Parameter(GainAutomation, 0.0, 1.0, 1.0)), // FIXME: GainAutomation? , normative_curve (Evoral::Parameter(GainAutomation))
normative_curve (Evoral::Parameter(GainAutomation)), , gain_curve (Evoral::Parameter(GainAutomation))
gain_curve (Evoral::Parameter(GainAutomation))
{ {
} }
@ -726,7 +725,7 @@ CrossfadeEditor::redraw ()
fade[current].shading->property_points() = spts; fade[current].shading->property_points() = spts;
for (vector<ArdourCanvas::WaveView*>::iterator i = fade[current].waves.begin(); i != fade[current].waves.end(); ++i) { for (vector<ArdourCanvas::WaveView*>::iterator i = fade[current].waves.begin(); i != fade[current].waves.end(); ++i) {
(*i)->property_gain_src() = &fade[current].gain_curve; (*i)->property_gain_src() = static_cast<Evoral::Curve*>(&fade[current].gain_curve.curve());
} }
} }
@ -1124,7 +1123,7 @@ CrossfadeEditor::make_waves (boost::shared_ptr<AudioRegion> region, WhichFade wh
waveview->property_sourcefile_length_function() = (void*) sourcefile_length_from_c; waveview->property_sourcefile_length_function() = (void*) sourcefile_length_from_c;
waveview->property_peak_function() = (void*) region_read_peaks_from_c; waveview->property_peak_function() = (void*) region_read_peaks_from_c;
waveview->property_gain_function() = (void*) curve_get_vector_from_c; waveview->property_gain_function() = (void*) curve_get_vector_from_c;
waveview->property_gain_src() = &fade[which].gain_curve; waveview->property_gain_src() = static_cast<Evoral::Curve*>(&fade[which].gain_curve.curve());
waveview->property_x() = canvas_border; waveview->property_x() = canvas_border;
waveview->property_y() = yoff; waveview->property_y() = yoff;
waveview->property_height() = ht; waveview->property_height() = ht;

View file

@ -96,8 +96,7 @@ class CrossfadeEditor : public ArdourDialog
void move_to (double x, double y, double xfract, double yfract); void move_to (double x, double y, double xfract, double yfract);
}; };
struct PointSorter struct PointSorter {
{
bool operator() (const CrossfadeEditor::Point* a, const CrossfadeEditor::Point *b) { bool operator() (const CrossfadeEditor::Point* a, const CrossfadeEditor::Point *b) {
return a->x < b->x; return a->x < b->x;
} }

View file

@ -85,6 +85,7 @@ class AutomationList : public PBD::StatefulDestructible, public Evoral::ControlL
XMLNode& serialize_events (); XMLNode& serialize_events ();
private: private:
void create_curve_if_necessary ();
int deserialize_events (const XMLNode&); int deserialize_events (const XMLNode&);
void maybe_signal_changed (); void maybe_signal_changed ();

View file

@ -703,7 +703,6 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
sigc::signal<void> NamedSelectionRemoved; sigc::signal<void> NamedSelectionRemoved;
/* Curves and AutomationLists (TODO when they go away) */ /* Curves and AutomationLists (TODO when they go away) */
void add_curve(Evoral::Curve*);
void add_automation_list(AutomationList*); void add_automation_list(AutomationList*);
/* fade curves */ /* fade curves */

View file

@ -24,6 +24,8 @@
#include <pbd/error.h> #include <pbd/error.h>
#include <pbd/enumwriter.h> #include <pbd/enumwriter.h>
#include <evoral/Curve.hpp>
#include <ardour/audio_track.h> #include <ardour/audio_track.h>
#include <ardour/audio_diskstream.h> #include <ardour/audio_diskstream.h>
#include <ardour/session.h> #include <ardour/session.h>

View file

@ -35,6 +35,8 @@
#include <pbd/enumwriter.h> #include <pbd/enumwriter.h>
#include <pbd/convert.h> #include <pbd/convert.h>
#include <evoral/Curve.hpp>
#include <ardour/audioregion.h> #include <ardour/audioregion.h>
#include <ardour/session.h> #include <ardour/session.h>
#include <ardour/gain.h> #include <ardour/gain.h>

View file

@ -50,7 +50,6 @@ static void dumpit (const AutomationList& al, string prefix = "")
} }
#endif #endif
/* XXX: min_val max_val redundant? (param.min() param.max()) */
AutomationList::AutomationList (Evoral::Parameter id) AutomationList::AutomationList (Evoral::Parameter id)
: ControlList(id) : ControlList(id)
{ {
@ -58,6 +57,8 @@ AutomationList::AutomationList (Evoral::Parameter id)
_style = Absolute; _style = Absolute;
_touching = false; _touching = false;
create_curve_if_necessary();
assert(_parameter.type() != NullAutomation); assert(_parameter.type() != NullAutomation);
AutomationListCreated(this); AutomationListCreated(this);
} }
@ -69,6 +70,8 @@ AutomationList::AutomationList (const AutomationList& other)
_state = other._state; _state = other._state;
_touching = other._touching; _touching = other._touching;
create_curve_if_necessary();
assert(_parameter.type() != NullAutomation); assert(_parameter.type() != NullAutomation);
AutomationListCreated(this); AutomationListCreated(this);
} }
@ -80,6 +83,8 @@ AutomationList::AutomationList (const AutomationList& other, double start, doubl
_state = other._state; _state = other._state;
_touching = other._touching; _touching = other._touching;
create_curve_if_necessary();
assert(_parameter.type() != NullAutomation); assert(_parameter.type() != NullAutomation);
AutomationListCreated(this); AutomationListCreated(this);
} }
@ -96,8 +101,11 @@ AutomationList::AutomationList (const XMLNode& node, Evoral::Parameter id)
set_state (node); set_state (node);
if (id) if (id) {
_parameter = id; _parameter = id;
}
create_curve_if_necessary();
assert(_parameter.type() != NullAutomation); assert(_parameter.type() != NullAutomation);
AutomationListCreated(this); AutomationListCreated(this);
@ -114,6 +122,22 @@ AutomationList::create(Evoral::Parameter id)
return boost::shared_ptr<Evoral::ControlList>(new AutomationList(id)); return boost::shared_ptr<Evoral::ControlList>(new AutomationList(id));
} }
void
AutomationList::create_curve_if_necessary()
{
switch (_parameter.type()) {
case GainAutomation:
case PanAutomation:
case FadeInAutomation:
case FadeOutAutomation:
case EnvelopeAutomation:
create_curve();
break;
default:
break;
}
}
bool bool
AutomationList::operator== (const AutomationList& other) AutomationList::operator== (const AutomationList& other)
{ {

View file

@ -37,6 +37,8 @@
#include <pbd/xml++.h> #include <pbd/xml++.h>
#include <pbd/enumwriter.h> #include <pbd/enumwriter.h>
#include <evoral/Curve.hpp>
#include <ardour/session.h> #include <ardour/session.h>
#include <ardour/panner.h> #include <ardour/panner.h>
#include <ardour/utils.h> #include <ardour/utils.h>

View file

@ -27,6 +27,8 @@
#include <pbd/stacktrace.h> #include <pbd/stacktrace.h>
#include <pbd/memento_command.h> #include <pbd/memento_command.h>
#include <evoral/Curve.hpp>
#include <ardour/timestamps.h> #include <ardour/timestamps.h>
#include <ardour/audioengine.h> #include <ardour/audioengine.h>
#include <ardour/route.h> #include <ardour/route.h>

View file

@ -35,6 +35,7 @@
#include <pbd/id.h> #include <pbd/id.h>
#include <pbd/statefuldestructible.h> #include <pbd/statefuldestructible.h>
#include <pbd/failed_constructor.h> #include <pbd/failed_constructor.h>
#include <evoral/Curve.hpp>
using namespace PBD; using namespace PBD;
using namespace ARDOUR; using namespace ARDOUR;

View file

@ -25,10 +25,10 @@
#include <glibmm/thread.h> #include <glibmm/thread.h>
#include "evoral/types.hpp" #include "evoral/types.hpp"
#include "evoral/Parameter.hpp" #include "evoral/Parameter.hpp"
#include "evoral/Curve.hpp"
namespace Evoral { namespace Evoral {
class Curve;
/** A single event (time-stamped value) for a control /** A single event (time-stamped value) for a control
*/ */
@ -216,8 +216,11 @@ public:
bool rt_safe_earliest_event (double start, double end, double& x, double& y, bool start_inclusive=false) const; bool rt_safe_earliest_event (double start, double end, double& x, double& y, bool start_inclusive=false) const;
bool rt_safe_earliest_event_unlocked (double start, double end, double& x, double& y, bool start_inclusive=false) const; bool rt_safe_earliest_event_unlocked (double start, double end, double& x, double& y, bool start_inclusive=false) const;
Curve& curve() { return *_curve; } void create_curve();
const Curve& curve() const { return *_curve; } void destroy_curve();
Curve& curve() { assert(_curve); return *_curve; }
const Curve& curve() const { assert(_curve); return *_curve; }
virtual void mark_dirty () const; virtual void mark_dirty () const;

View file

@ -21,6 +21,7 @@
#include <utility> #include <utility>
#include <iostream> #include <iostream>
#include "evoral/ControlList.hpp" #include "evoral/ControlList.hpp"
#include "evoral/Curve.hpp"
using namespace std; using namespace std;
@ -36,7 +37,7 @@ inline bool event_time_less_than (ControlEvent* a, ControlEvent* b)
ControlList::ControlList (const Parameter& id) ControlList::ControlList (const Parameter& id)
: _parameter(id) : _parameter(id)
, _interpolation(Linear) , _interpolation(Linear)
, _curve(new Curve(*this)) , _curve(0)
{ {
_frozen = 0; _frozen = 0;
_changed_when_thawed = false; _changed_when_thawed = false;
@ -54,7 +55,7 @@ ControlList::ControlList (const Parameter& id)
ControlList::ControlList (const ControlList& other) ControlList::ControlList (const ControlList& other)
: _parameter(other._parameter) : _parameter(other._parameter)
, _interpolation(Linear) , _interpolation(Linear)
, _curve(new Curve(*this)) , _curve(0)
{ {
_frozen = 0; _frozen = 0;
_changed_when_thawed = false; _changed_when_thawed = false;
@ -77,7 +78,7 @@ ControlList::ControlList (const ControlList& other)
ControlList::ControlList (const ControlList& other, double start, double end) ControlList::ControlList (const ControlList& other, double start, double end)
: _parameter(other._parameter) : _parameter(other._parameter)
, _interpolation(Linear) , _interpolation(Linear)
, _curve(new Curve(*this)) , _curve(0)
{ {
_frozen = 0; _frozen = 0;
_changed_when_thawed = false; _changed_when_thawed = false;
@ -147,6 +148,19 @@ ControlList::operator= (const ControlList& other)
return *this; return *this;
} }
void
ControlList::create_curve()
{
_curve = new Curve(*this);
}
void
ControlList::destroy_curve()
{
delete _curve;
_curve = NULL;
}
void void
ControlList::maybe_signal_changed () ControlList::maybe_signal_changed ()
{ {