check for multiple tempo/meter marks at the same location, which somehow ardour2...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 Jul 2012 13:12:25 +0000 (13:12 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 Jul 2012 13:12:25 +0000 (13:12 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@13082 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/tempo.cc

index e64a1169333023bf72021c3f86b144cbe549d6d4..f96bb5a91aaf33bb632760e55f2c0faf8c44a6d0 100644 (file)
@@ -1012,6 +1012,7 @@ TempoMap::_extend_map (TempoSection* tempo, MeterSection* meter,
                                        */
                                        goto set_metrics;
                                }
+
                        }
                } 
 
@@ -1645,6 +1646,28 @@ TempoMap::set_state (const XMLNode& node, int /*version*/)
                        metrics.sort (cmp);
                }
 
+               /* check for multiple tempo/meters at the same location, which
+                  ardour2 somehow allowed.
+               */
+
+               Metrics::iterator prev = metrics.end();
+               for (Metrics::iterator i = metrics.begin(); i != metrics.end(); ++i) {
+                       if (prev != metrics.end()) {
+                               if (dynamic_cast<MeterSection*>(*prev) && dynamic_cast<MeterSection*>(*i)) {
+                                       if ((*prev)->start() == (*i)->start()) {
+                                               error << string_compose (_("Multiple meter definitions found at %1"), (*prev)->start()) << endmsg;
+                                               return -1;
+                                       }
+                               } else if (dynamic_cast<TempoSection*>(*prev) && dynamic_cast<TempoSection*>(*i)) {
+                                       if ((*prev)->start() == (*i)->start()) {
+                                               error << string_compose (_("Multiple tempo definitions found at %1"), (*prev)->start()) << endmsg;
+                                               return -1;
+                                       }
+                               }
+                       }
+                       prev = i;
+               }
+
                recompute_map (true, -1);
        }