From: <ygu...@us...> - 2008-06-13 20:16:20
|
Revision: 8900 http://rosegarden.svn.sourceforge.net/rosegarden/?rev=8900&view=rev Author: yguillemot Date: 2008-06-13 13:16:18 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Yet another fix (I hope it's the last one ...) of bug #1961378. The last issue was clef jumping from start to middle of segment when a range is cut. - The fix forces SegmentJoinCommand to always use the leftmost segment first when creating the new segment. If some clef or key change are found at start of this leftmost segment, the join command will no more erase them. - Add some assert in SegmentSplitTwiceCommand (not directly related to preceding fix, just in case ...) Modified Paths: -------------- trunk/rosegarden/src/commands/segment/SegmentJoinCommand.cpp trunk/rosegarden/src/commands/segment/SegmentSplitTwiceCommand.cpp Modified: trunk/rosegarden/src/commands/segment/SegmentJoinCommand.cpp =================================================================== --- trunk/rosegarden/src/commands/segment/SegmentJoinCommand.cpp 2008-06-13 12:03:52 UTC (rev 8899) +++ trunk/rosegarden/src/commands/segment/SegmentJoinCommand.cpp 2008-06-13 20:16:18 UTC (rev 8900) @@ -78,12 +78,27 @@ if (!m_newSegment) { - m_newSegment = new Segment(*m_oldSegments[0]); + // Find out the leftmost segment + timeT t0 = m_oldSegments[0]->getStartTime(); + unsigned int i0 = 0; + for (unsigned int i = 1; i < m_oldSegments.size(); ++i) { + timeT t = m_oldSegments[i]->getStartTime(); + if (t < t0) { + t0 = t; + i0 = i; + } + } - // that duplicated segment 0; now do the rest + // Always begin with the leftmost segment to keep in the new segment + // any clef or key change found at the start of this segment. + m_newSegment = new Segment(*m_oldSegments[i0]); - for (unsigned int i = 1; i < m_oldSegments.size(); ++i) { + // that duplicated segment i0; now do the rest + for (unsigned int i = 0; i < m_oldSegments.size(); ++i) { + + if (i == i0) continue; // Don't add twice the first old segment + Segment *s = m_oldSegments[i]; timeT start = s->getStartTime(), end = s->getEndMarkerTime(); Modified: trunk/rosegarden/src/commands/segment/SegmentSplitTwiceCommand.cpp =================================================================== --- trunk/rosegarden/src/commands/segment/SegmentSplitTwiceCommand.cpp 2008-06-13 12:03:52 UTC (rev 8899) +++ trunk/rosegarden/src/commands/segment/SegmentSplitTwiceCommand.cpp 2008-06-13 20:16:18 UTC (rev 8900) @@ -53,6 +53,16 @@ m_composition(segment->getComposition()), m_rejoins(rejoins) { + + // This command should not be called if the range doesn't cut the + // segment twice + assert(splitTime1 > segment->getStartTime()); + assert(splitTime1 < segment->getEndMarkerTime()); + assert(splitTime2 < segment->getEndMarkerTime()); + assert(splitTime2 > segment->getStartTime()); + assert(splitTime1 < splitTime2); + + } SegmentSplitTwiceCommand::~SegmentSplitTwiceCommand() @@ -78,9 +88,6 @@ return; } - // This method should not have been called if the range don't cut the - // segment twice (test done in DeleteRangeCommand) - SegmentSplitCommand split1 = SegmentSplitCommand(m_segment, m_splitTime1, true); split1.execute(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |