Resolve copy-c'tor and assignment issue with TempoMap
There are various issues with copy-construction: no readlock is taken, Tempo/Metric Sections were static-cast to non-const pointers and passed as references... This remove the [now] unused copy-c'tor, and fixes various const issues.
This commit is contained in:
parent
448bc635e5
commit
a9ca7f649a
@ -323,7 +323,6 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TempoMap (framecnt_t frame_rate);
|
TempoMap (framecnt_t frame_rate);
|
||||||
TempoMap (TempoMap const &);
|
|
||||||
~TempoMap();
|
~TempoMap();
|
||||||
|
|
||||||
TempoMap& operator= (TempoMap const &);
|
TempoMap& operator= (TempoMap const &);
|
||||||
@ -519,6 +518,8 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
|
|||||||
void fix_legacy_end_session();
|
void fix_legacy_end_session();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/* prevent copy construction */
|
||||||
|
TempoMap (TempoMap const&);
|
||||||
|
|
||||||
TempoSection* previous_tempo_section_locked (const Metrics& metrics, TempoSection*) const;
|
TempoSection* previous_tempo_section_locked (const Metrics& metrics, TempoSection*) const;
|
||||||
TempoSection* next_tempo_section_locked (const Metrics& metrics, TempoSection*) const;
|
TempoSection* next_tempo_section_locked (const Metrics& metrics, TempoSection*) const;
|
||||||
@ -604,8 +605,8 @@ private:
|
|||||||
bool remove_tempo_locked (const TempoSection&);
|
bool remove_tempo_locked (const TempoSection&);
|
||||||
bool remove_meter_locked (const MeterSection&);
|
bool remove_meter_locked (const MeterSection&);
|
||||||
|
|
||||||
TempoSection* copy_metrics_and_point (const Metrics& metrics, Metrics& copy, TempoSection* section);
|
TempoSection* copy_metrics_and_point (const Metrics& metrics, Metrics& copy, TempoSection* section) const;
|
||||||
MeterSection* copy_metrics_and_point (const Metrics& metrics, Metrics& copy, MeterSection* section);
|
MeterSection* copy_metrics_and_point (const Metrics& metrics, Metrics& copy, MeterSection* section) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; /* namespace ARDOUR */
|
}; /* namespace ARDOUR */
|
||||||
|
@ -784,27 +784,12 @@ TempoMap::TempoMap (framecnt_t fr)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TempoMap::TempoMap (TempoMap const & other)
|
|
||||||
{
|
|
||||||
_frame_rate = other._frame_rate;
|
|
||||||
for (Metrics::const_iterator m = other._metrics.begin(); m != other._metrics.end(); ++m) {
|
|
||||||
TempoSection* ts = dynamic_cast<TempoSection*> (*m);
|
|
||||||
MeterSection* ms = dynamic_cast<MeterSection*> (*m);
|
|
||||||
|
|
||||||
if (ts) {
|
|
||||||
TempoSection* new_section = new TempoSection (*ts);
|
|
||||||
_metrics.push_back (new_section);
|
|
||||||
} else {
|
|
||||||
MeterSection* new_section = new MeterSection (*ms);
|
|
||||||
_metrics.push_back (new_section);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TempoMap&
|
TempoMap&
|
||||||
TempoMap::operator= (TempoMap const & other)
|
TempoMap::operator= (TempoMap const & other)
|
||||||
{
|
{
|
||||||
if (&other != this) {
|
if (&other != this) {
|
||||||
|
Glib::Threads::RWLock::ReaderLock lr (other.lock);
|
||||||
|
Glib::Threads::RWLock::WriterLock lm (lock);
|
||||||
_frame_rate = other._frame_rate;
|
_frame_rate = other._frame_rate;
|
||||||
|
|
||||||
Metrics::const_iterator d = _metrics.begin();
|
Metrics::const_iterator d = _metrics.begin();
|
||||||
@ -815,8 +800,8 @@ TempoMap::operator= (TempoMap const & other)
|
|||||||
_metrics.clear();
|
_metrics.clear();
|
||||||
|
|
||||||
for (Metrics::const_iterator m = other._metrics.begin(); m != other._metrics.end(); ++m) {
|
for (Metrics::const_iterator m = other._metrics.begin(); m != other._metrics.end(); ++m) {
|
||||||
TempoSection* ts = dynamic_cast<TempoSection*> (*m);
|
TempoSection const * const ts = dynamic_cast<TempoSection const * const> (*m);
|
||||||
MeterSection* ms = dynamic_cast<MeterSection*> (*m);
|
MeterSection const * const ms = dynamic_cast<MeterSection const * const> (*m);
|
||||||
|
|
||||||
if (ts) {
|
if (ts) {
|
||||||
TempoSection* new_section = new TempoSection (*ts);
|
TempoSection* new_section = new TempoSection (*ts);
|
||||||
@ -3140,15 +3125,13 @@ TempoMap::solve_map_bbt (Metrics& imaginary, MeterSection* section, const BBT_Ti
|
|||||||
* to section's equivalent in copy.
|
* to section's equivalent in copy.
|
||||||
*/
|
*/
|
||||||
TempoSection*
|
TempoSection*
|
||||||
TempoMap::copy_metrics_and_point (const Metrics& metrics, Metrics& copy, TempoSection* section)
|
TempoMap::copy_metrics_and_point (const Metrics& metrics, Metrics& copy, TempoSection* section) const
|
||||||
{
|
{
|
||||||
TempoSection* ret = 0;
|
TempoSection* ret = 0;
|
||||||
|
|
||||||
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
|
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
|
||||||
TempoSection* t;
|
|
||||||
MeterSection* m;
|
|
||||||
if ((*i)->is_tempo()) {
|
if ((*i)->is_tempo()) {
|
||||||
t = static_cast<TempoSection*> (*i);
|
TempoSection const * const t = dynamic_cast<TempoSection const * const> (*i);
|
||||||
if (t == section) {
|
if (t == section) {
|
||||||
ret = new TempoSection (*t);
|
ret = new TempoSection (*t);
|
||||||
copy.push_back (ret);
|
copy.push_back (ret);
|
||||||
@ -3157,9 +3140,8 @@ TempoMap::copy_metrics_and_point (const Metrics& metrics, Metrics& copy, TempoSe
|
|||||||
|
|
||||||
TempoSection* cp = new TempoSection (*t);
|
TempoSection* cp = new TempoSection (*t);
|
||||||
copy.push_back (cp);
|
copy.push_back (cp);
|
||||||
}
|
} else {
|
||||||
if (!(*i)->is_tempo()) {
|
MeterSection const * const m = dynamic_cast<MeterSection const * const> (*i);
|
||||||
m = static_cast<MeterSection *> (*i);
|
|
||||||
MeterSection* cp = new MeterSection (*m);
|
MeterSection* cp = new MeterSection (*m);
|
||||||
copy.push_back (cp);
|
copy.push_back (cp);
|
||||||
}
|
}
|
||||||
@ -3169,21 +3151,17 @@ TempoMap::copy_metrics_and_point (const Metrics& metrics, Metrics& copy, TempoSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
MeterSection*
|
MeterSection*
|
||||||
TempoMap::copy_metrics_and_point (const Metrics& metrics, Metrics& copy, MeterSection* section)
|
TempoMap::copy_metrics_and_point (const Metrics& metrics, Metrics& copy, MeterSection* section) const
|
||||||
{
|
{
|
||||||
MeterSection* ret = 0;
|
MeterSection* ret = 0;
|
||||||
|
|
||||||
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
|
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
|
||||||
TempoSection* t;
|
|
||||||
MeterSection* m;
|
|
||||||
if ((*i)->is_tempo()) {
|
if ((*i)->is_tempo()) {
|
||||||
t = static_cast<TempoSection*> (*i);
|
TempoSection const * const t = dynamic_cast<TempoSection const * const> (*i);
|
||||||
TempoSection* cp = new TempoSection (*t);
|
TempoSection* cp = new TempoSection (*t);
|
||||||
copy.push_back (cp);
|
copy.push_back (cp);
|
||||||
}
|
} else {
|
||||||
|
MeterSection const * const m = dynamic_cast<MeterSection const * const> (*i);
|
||||||
if (!(*i)->is_tempo()) {
|
|
||||||
m = static_cast<MeterSection *> (*i);
|
|
||||||
if (m == section) {
|
if (m == section) {
|
||||||
ret = new MeterSection (*m);
|
ret = new MeterSection (*m);
|
||||||
copy.push_back (ret);
|
copy.push_back (ret);
|
||||||
|
Loading…
Reference in New Issue
Block a user