Skip to content

Commit

Permalink
fix #278366 Slides: user positions set in 2.x are lost
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Dec 4, 2018
1 parent f15c236 commit 584e193
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 10 additions & 4 deletions libmscore/read206.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,10 @@ bool readChordProperties206(XmlReader& e, Chord* ch)
else if (tag == "ChordLine") {
ChordLine* cl = new ChordLine(ch->score());
cl->read(e);
QPointF o = cl->offset();
cl->setOffset(0.0, 0.0);
ch->add(cl);
e.fixOffsets().append({cl, o});
}
else
return false;
Expand Down Expand Up @@ -3727,20 +3730,16 @@ void PageFormat::read(XmlReader& e)
_printableWidth = qMin(w1, w2); // silently adjust right margins
}


//---------------------------------------------------------
// read206
// import old version > 1.3 and < 3.x files
//---------------------------------------------------------

Score::FileError MasterScore::read206(XmlReader& e)
{
// qDebug("read206");

for (unsigned int i = 0; i < sizeof(style206)/sizeof(*style206); ++i)
style().set(style206[i].idx, style206[i].val);


while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "programVersion") {
Expand Down Expand Up @@ -3800,6 +3799,13 @@ Score::FileError MasterScore::read206(XmlReader& e)
staffIdx += sp;
}

// fix positions
// offset = saved offset - layout position
doLayout();
for (auto i : e.fixOffsets()) {
i.first->setOffset(i.second - i.first->pos());
}

// treat reading a 2.06 file as import
// on save warn if old file will be overwritten
setCreated(true);
Expand Down
3 changes: 3 additions & 0 deletions libmscore/xml.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class XmlReader : public QXmlStreamReader {
QList<SpannerValues> _spannerValues;
QList<std::pair<int,Spanner*>> _spanner;
QList<StaffType> _staffTypes;
QList<std::pair<Element*, QPointF>> _fixOffsets;

QList<ConnectorInfoReader> _connectors;
QList<ConnectorInfoReader> _pendingConnectors; // connectors that are pending to be updated and added to _connectors. That will happen when checkConnectors() is called.
Expand Down Expand Up @@ -193,6 +194,8 @@ class XmlReader : public QXmlStreamReader {
void checkTuplets();
Tid addUserTextStyle(const QString& name);
Tid lookupUserTextStyle(const QString& name);

QList<std::pair<Element*, QPointF>>& fixOffsets() { return _fixOffsets; }
};

//---------------------------------------------------------
Expand Down

0 comments on commit 584e193

Please sign in to comment.