From: Chris C. <ca...@us...> - 2005-03-27 19:38:45
|
Update of /cvsroot/rosegarden/base In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1292 Modified Files: Tag: V1_0 SegmentPerformanceHelper.C Log Message: * Fix for #1171463, across from HEAD Index: SegmentPerformanceHelper.C =================================================================== RCS file: /cvsroot/rosegarden/base/SegmentPerformanceHelper.C,v retrieving revision 1.35 retrieving revision 1.35.2.1 diff -C2 -d -r1.35 -r1.35.2.1 *** SegmentPerformanceHelper.C 8 Feb 2005 14:55:47 -0000 1.35 --- SegmentPerformanceHelper.C 27 Mar 2005 19:38:37 -0000 1.35.2.1 *************** *** 42,45 **** --- 42,46 ---- Event *e = *i; if (!e->isa(Note::EventType)) return c; + Segment::iterator j(i); bool tiedBack = false, tiedForward = false; *************** *** 47,64 **** e->get<Bool>(TIED_FORWARD, tiedForward); - if (tiedBack) return iteratorcontainer(); - else if (!tiedForward) return c; - - timeT t = e->getAbsoluteTime(); timeT d = e->getDuration(); if (!e->has(PITCH)) return c; int pitch = e->get<Int>(PITCH); for (;;) { ! while (++i != end() && !(*i)->isa(Note::EventType)); ! if (i == end()) return c; ! e = *i; timeT t2 = e->getAbsoluteTime(); --- 48,97 ---- e->get<Bool>(TIED_FORWARD, tiedForward); timeT d = e->getDuration(); + timeT t = e->getAbsoluteTime(); if (!e->has(PITCH)) return c; int pitch = e->get<Int>(PITCH); + bool valid = false; + + if (tiedBack) { + // #1171463: If we can find no preceding TIED_FORWARD event, + // then we remove this property + + while (j != begin()) { + + --j; + if (!(*j)->isa(Note::EventType)) continue; + e = *j; // can reuse e because this branch always returns + + timeT t2 = e->getAbsoluteTime() + e->getDuration(); + if (t2 < t) break; + + if (t2 > t || !e->has(PITCH) || + e->get<Int>(PITCH) != pitch) continue; + + bool prevTiedForward = false; + if (!e->get<Bool>(TIED_FORWARD, prevTiedForward) || + !prevTiedForward) break; + + valid = true; + break; + } + + if (valid) { + return iteratorcontainer(); + } else { + (*i)->unset(TIED_BACKWARD); + return c; + } + } + else if (!tiedForward) return c; + for (;;) { ! while (++j != end() && !(*j)->isa(Note::EventType)); ! if (j == end()) return c; ! e = *j; timeT t2 = e->getAbsoluteTime(); *************** *** 72,76 **** d += e->getDuration(); ! c.push_back(i); if (!e->get<Bool>(TIED_FORWARD, tiedForward) || --- 105,110 ---- d += e->getDuration(); ! c.push_back(j); ! valid = true; if (!e->get<Bool>(TIED_FORWARD, tiedForward) || *************** *** 78,81 **** --- 112,121 ---- } + if (!valid) { + // Related to #1171463: If we can find no following + // TIED_BACKWARD event, then we remove this property + (*i)->unset(TIED_FORWARD); + } + return c; } *************** *** 94,112 **** if (!(*i)->has(TIED_BACKWARD)) { ! if (!(*i)->has(TIED_FORWARD) || !(*i)->isa(Note::EventType)) { ! d = (*i)->getDuration(); ! } else { ! // tied forward but not back ! iteratorcontainer c(getTiedNotes(i)); ! for (iteratorcontainer::iterator ci = c.begin(); ! ci != c.end(); ++ci) { ! d += (**ci)->getDuration(); ! } } } --- 134,167 ---- if (!(*i)->has(TIED_BACKWARD)) { + + // Formerly we just returned d in this case, but now we check + // with getTiedNotes so as to remove any bogus backward ties + // that have no corresponding forward tie. Unfortunately this + // is quite a bit slower. ! //!!! optimize. at least we should add a marker property to ! //anything we've already processed from this helper this time ! //around. ! iteratorcontainer c(getTiedNotes(i)); ! ! if (c.empty()) { // the tie back is valid ! return 0; ! } ! } ! if (!(*i)->has(TIED_FORWARD) || !(*i)->isa(Note::EventType)) { ! d = (*i)->getDuration(); ! } else { ! ! // tied forward but not back ! ! iteratorcontainer c(getTiedNotes(i)); ! for (iteratorcontainer::iterator ci = c.begin(); ! ci != c.end(); ++ci) { ! d += (**ci)->getDuration(); } } |