From 42309d76c0d60b89f09f3eae0fc15fb4b523ed1f Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Mon, 26 Sep 2011 04:50:36 +0200 Subject: [PATCH] Fix paste bugs --- Sources/VLModel.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Sources/VLModel.cpp b/Sources/VLModel.cpp index 26efeeb..15c4abc 100644 --- a/Sources/VLModel.cpp +++ b/Sources/VLModel.cpp @@ -2033,23 +2033,27 @@ void VLSong::PasteMeasures(size_t beginMeasure, const VLSong & measures, int mod size_t nextMeasure = mode==kInsert ? beginMeasure : beginMeasure+numMeas; if (mode == kInsert) { - int propAt = fMeasures[beginMeasure].fPropIdx; - int propOffset = 0; + int propAt = fMeasures[beginMeasure].fPropIdx; + int propOffset = 0; + bool sectionBreak= false; VLPropertyList::const_iterator beginProp = measures.fProperties.begin(); VLPropertyList::const_iterator endProp = measures.fProperties.end(); if (beginMeasure) { - propOffset = fMeasures[beginMeasure-1].fPropIdx; + propOffset = fMeasures[beginMeasure-1].fPropIdx; + sectionBreak= propAt > propOffset; if (fProperties[propOffset] == beginProp[0]) ++beginProp; else ++propOffset; - if (endProp > beginProp && fProperties[propAt] == endProp[-1]) - --endProp; } + if (endProp > beginProp && fProperties[propAt] == endProp[-1] + && (sectionBreak || (endProp-beginProp) == 1) + ) + --endProp; ptrdiff_t postOffset = endProp - beginProp; - fProperties.insert(fProperties.begin()+propAt, beginProp, endProp); + fProperties.insert(fProperties.begin()+propAt+!sectionBreak, beginProp, endProp); fMeasures.insert(fMeasures.begin()+beginMeasure, measures.fMeasures.begin(), measures.fMeasures.end()); if (propOffset)