comparison layer/TimeInstantLayer.cpp @ 1533:37df1530519d

Fix failure to apply new frame when pasting events
author Chris Cannam
date Wed, 09 Oct 2019 11:51:19 +0100
parents 36ad3cdabf55
children 4f8c72adbf43
comparison
equal deleted inserted replaced
1532:14a162f6870f 1533:37df1530519d
761 to.addPoint(p.withReferenceFrame(alignToReference(v, p.getFrame()))); 761 to.addPoint(p.withReferenceFrame(alignToReference(v, p.getFrame())));
762 } 762 }
763 } 763 }
764 764
765 bool 765 bool
766 TimeInstantLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t frameOffset, bool) 766 TimeInstantLayer::paste(LayerGeometryProvider *v, const Clipboard &from,
767 sv_frame_t frameOffset, bool)
767 { 768 {
768 auto model = ModelById::getAs<SparseOneDimensionalModel>(m_model); 769 auto model = ModelById::getAs<SparseOneDimensionalModel>(m_model);
769 if (!model) return false; 770 if (!model) return false;
770 771
771 EventVector points = from.getPoints(); 772 EventVector points = from.getPoints();
815 else if (frameOffset < 0) { 816 else if (frameOffset < 0) {
816 if (frame > -frameOffset) frame += frameOffset; 817 if (frame > -frameOffset) frame += frameOffset;
817 else frame = 0; 818 else frame = 0;
818 } 819 }
819 820
820 Event newPoint = *i; 821 Event newPoint = i->withFrame(frame);
822
821 if (!i->hasLabel() && i->hasValue()) { 823 if (!i->hasLabel() && i->hasValue()) {
822 newPoint = newPoint.withLabel(QString("%1").arg(i->getValue())); 824 newPoint = newPoint.withLabel(QString("%1").arg(i->getValue()));
823 } 825 }
824 826
825 command->add(newPoint); 827 command->add(newPoint);