From 8b8be3efa1f021160554cd930b44f8820805056d Mon Sep 17 00:00:00 2001 From: ws Date: Thu, 30 Oct 2014 09:36:30 +0100 Subject: [PATCH] make score->save() undo-safe --- libmscore/scorefile.cpp | 22 ++++++++++++------- .../libmscore/selectionfilter/updateReference | 5 +++++ thirdparty/xmlstream/.gitignore | 2 ++ 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100755 mtest/libmscore/selectionfilter/updateReference create mode 100644 thirdparty/xmlstream/.gitignore diff --git a/libmscore/scorefile.cpp b/libmscore/scorefile.cpp index babadab750..440692a44c 100644 --- a/libmscore/scorefile.cpp +++ b/libmscore/scorefile.cpp @@ -91,21 +91,24 @@ void Score::write(Xml& xml, bool selectionOnly) // then some layout information is missing: // relayout with all parts set visible + QList hiddenParts; bool unhide = false; - QList partsVisible; if (styleB(StyleIdx::createMultiMeasureRests)) { for (Part* part : _parts) { - partsVisible.append(part->show()); if (!part->show()) { - unhide = true; - part->setShow(true); + if (!unhide) { + startCmd(); + unhide = true; + } + undo(new ChangePartProperty(part, 0, true)); + hiddenParts.append(part); } } } if (unhide) { doLayout(); - for (int i = 0; i < partsVisible.size(); ++i) - _parts[i]->setShow(partsVisible[i]); + for (Part* p : hiddenParts) + p->setShow(false); } xml.stag("Score"); @@ -227,8 +230,11 @@ void Score::write(Xml& xml, bool selectionOnly) xml.tag("name", name()); xml.etag(); - if (unhide) - doLayout(); + if (unhide) { + endCmd(); + undo()->undo(); + endUndoRedo(); + } } //--------------------------------------------------------- diff --git a/mtest/libmscore/selectionfilter/updateReference b/mtest/libmscore/selectionfilter/updateReference new file mode 100755 index 0000000000..6ecbe5d852 --- /dev/null +++ b/mtest/libmscore/selectionfilter/updateReference @@ -0,0 +1,5 @@ +#!/bin/bash + +cp ../../../build.debug/mtest/libmscore/selectionfilter/selectionfilter8-base.xml selectionfilter8-base-ref.xml +cp ../../../build.debug/mtest/libmscore/selectionfilter/selectionfilter9-base.xml selectionfilter9-base-ref.xml + diff --git a/thirdparty/xmlstream/.gitignore b/thirdparty/xmlstream/.gitignore new file mode 100644 index 0000000000..148363ca03 --- /dev/null +++ b/thirdparty/xmlstream/.gitignore @@ -0,0 +1,2 @@ +out +