Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #97931: system initial barline type lost on reload #2386

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2273,14 +2273,7 @@ void Measure::read(XmlReader& e, int staffIdx)
else if (tag == "breakMultiMeasureRest")
_breakMultiMeasureRest = e.readBool();
else if (tag == "sysInitBarLineType") {
const QString& val(e.readElementText());
_systemInitialBarLineType = BarLineType::NORMAL;
for (unsigned i = 0; i < BarLine::barLineTableSize(); ++i) {
if (BarLine::barLineTypeName(BarLineType(i)) == val) {
_systemInitialBarLineType = BarLineType(i);
break;
}
}
_systemInitialBarLineType = BarLineType(Ms::getProperty(P_ID::SYSTEM_INITIAL_BARLINE_TYPE, e).toInt());
}
else if (tag == "Tuplet") {
Tuplet* tuplet = new Tuplet(score());
Expand Down
20 changes: 19 additions & 1 deletion libmscore/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "groups.h"
#include "xml.h"
#include "note.h"
#include "barline.h"

namespace Ms {

Expand Down Expand Up @@ -214,7 +215,7 @@ static const PropertyData propertyList[] = {
{ P_ID::VOLTA_ENDING, true, "endings", P_TYPE::INT_LIST },
{ P_ID::LINE_VISIBLE, true, "lineVisible", P_TYPE::BOOL },

{ P_ID::SYSTEM_INITIAL_BARLINE_TYPE, false, "sysInitBarLineType", P_TYPE::INT },
{ P_ID::SYSTEM_INITIAL_BARLINE_TYPE, false, "sysInitBarLineType", P_TYPE::BARLINE_TYPE },
{ P_ID::MAG, false, "mag", P_TYPE::REAL },
{ P_ID::USE_DRUMSET, false, "useDrumset", P_TYPE::BOOL },
{ P_ID::PART_VOLUME, false, "volume", P_TYPE::INT },
Expand Down Expand Up @@ -369,6 +370,23 @@ QVariant getProperty(P_ID id, XmlReader& e)
return QVariant(int(Element::Placement::BELOW));
}
break;
case P_TYPE::BARLINE_TYPE: {
bool ok;
const QString& val(e.readElementText());
int ct = val.toInt(&ok);
if (ok)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment to explain it used to be written as a int?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see this before, slrry. Should I still add the comment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed it too. Let me add it.

return QVariant(ct);
else {
for (unsigned i = 0; i < BarLine::barLineTableSize(); ++i) {
if (BarLine::barLineTypeName(BarLineType(i)) == val) {
ct = i;
break;
}
}
return QVariant(ct);
}
}
break;
case P_TYPE::BEAM_MODE: // TODO
return QVariant(int(0));

Expand Down
1 change: 1 addition & 0 deletions libmscore/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ enum class P_TYPE : char {
TEXT_STYLE,
INT_LIST,
GLISSANDO_STYLE,
BARLINE_TYPE,
};

extern QVariant getProperty(P_ID type, XmlReader& e);
Expand Down
18 changes: 11 additions & 7 deletions libmscore/xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "tuplet.h"
#include "sym.h"
#include "note.h"
#include "barline.h"

namespace Ms {

Expand Down Expand Up @@ -413,7 +414,7 @@ void Xml::tag(P_ID id, QVariant data, QVariant defaultData)
tag(name, data);
break;
case P_TYPE::ORNAMENT_STYLE:
switch ( MScore::OrnamentStyle(data.toInt())) {
switch (MScore::OrnamentStyle(data.toInt())) {
case MScore::OrnamentStyle::BAROQUE:
tag(name, QVariant("baroque"));
break;
Expand All @@ -423,7 +424,7 @@ void Xml::tag(P_ID id, QVariant data, QVariant defaultData)
}
break;
case P_TYPE::GLISSANDO_STYLE:
switch ( MScore::GlissandoStyle(data.toInt())) {
switch (MScore::GlissandoStyle(data.toInt())) {
case MScore::GlissandoStyle::BLACK_KEYS:
tag(name, QVariant("blackkeys"));
break;
Expand All @@ -439,7 +440,7 @@ void Xml::tag(P_ID id, QVariant data, QVariant defaultData)
}
break;
case P_TYPE::DIRECTION:
switch(MScore::Direction(data.toInt())) {
switch (MScore::Direction(data.toInt())) {
case MScore::Direction::UP:
tag(name, QVariant("up"));
break;
Expand All @@ -451,7 +452,7 @@ void Xml::tag(P_ID id, QVariant data, QVariant defaultData)
}
break;
case P_TYPE::DIRECTION_H:
switch(MScore::DirectionH(data.toInt())) {
switch (MScore::DirectionH(data.toInt())) {
case MScore::DirectionH::LEFT:
tag(name, QVariant("left"));
break;
Expand All @@ -463,7 +464,7 @@ void Xml::tag(P_ID id, QVariant data, QVariant defaultData)
}
break;
case P_TYPE::LAYOUT_BREAK:
switch(LayoutBreak::Type(data.toInt())) {
switch (LayoutBreak::Type(data.toInt())) {
case LayoutBreak::Type::LINE:
tag(name, QVariant("line"));
break;
Expand All @@ -476,7 +477,7 @@ void Xml::tag(P_ID id, QVariant data, QVariant defaultData)
}
break;
case P_TYPE::VALUE_TYPE:
switch(Note::ValueType(data.toInt())) {
switch (Note::ValueType(data.toInt())) {
case Note::ValueType::OFFSET_VAL:
tag(name, QVariant("offset"));
break;
Expand All @@ -486,7 +487,7 @@ void Xml::tag(P_ID id, QVariant data, QVariant defaultData)
}
break;
case P_TYPE::PLACEMENT:
switch(Element::Placement(data.toInt())) {
switch (Element::Placement(data.toInt())) {
case Element::Placement::ABOVE:
tag(name, QVariant("above"));
break;
Expand All @@ -498,6 +499,9 @@ void Xml::tag(P_ID id, QVariant data, QVariant defaultData)
case P_TYPE::SYMID:
tag(name, Sym::id2name(SymId(data.toInt())));
break;
case P_TYPE::BARLINE_TYPE:
tag(name, BarLine::barLineTypeName(BarLineType(data.toInt())));
break;
default:
Q_ASSERT(false);
}
Expand Down