Skip to content

Commit

Permalink
Fix XML tie import
Browse files Browse the repository at this point in the history
Backport of musescore#24640, plus fixing some clazy warnings, including some that fix null pointer dereferencing and fix 2 MSVC compiler warnings (reg. conversion from size_t to int and reg. declaration hides class member)
  • Loading branch information
miiizen authored and Jojo-Schmitz committed Oct 16, 2024
1 parent 8e9758d commit 089ef5b
Show file tree
Hide file tree
Showing 14 changed files with 2,386 additions and 65 deletions.
179 changes: 121 additions & 58 deletions importexport/musicxml/importmxmlpass2.cpp

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions importexport/musicxml/importmxmlpass2.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ using HairpinsStack = std::array<MusicXmlExtendedSpannerDesc, MAX_NUMBER_LEVEL>;
using InferredHairpinsStack = std::vector<Hairpin*>;
using SpannerStack = std::array<MusicXmlExtendedSpannerDesc, MAX_NUMBER_LEVEL>;
using SpannerSet = std::set<Spanner*>;
using MusicXMLTieMap = std::map<TieLocation, Tie*>;

//---------------------------------------------------------
// DelayedDirectionsList
Expand All @@ -222,7 +223,7 @@ class MusicXMLParserNotations {
void parse();
void addToScore(ChordRest* const cr, Note* const note, const int tick, SlurStack& slurs,
Glissando* glissandi[MAX_NUMBER_LEVEL][2], MusicXmlSpannerMap& spanners, TrillStack& trills,
std::map<int, Tie*>& ties);
MusicXMLTieMap& ties, std::vector<Note*>& unstartedTieNotes, std::vector<Note*>& unendedTieNotes);
QString errors() const { return _errors; }
MusicXmlTupletDesc tupletDesc() const { return _tupletDesc; }
bool hasTremolo() const { return _hasTremolo; }
Expand Down Expand Up @@ -363,10 +364,11 @@ class MusicXMLParserPass2 {

Glissando* _glissandi[MAX_NUMBER_LEVEL][2]; ///< Current slides ([0]) / glissandi ([1])

std::map<int, Tie*> _ties;
MusicXMLTieMap _ties;
Volta* _lastVolta;
bool _hasDrumset; ///< drumset defined TODO: move to pass 1

std::vector<Note*> _unstartedTieNotes;
std::vector<Note*> _unendedTieNotes;
MusicXmlSpannerMap _spanners;

MusicXmlExtendedSpannerDesc _pedal; ///< Current pedal
Expand Down
3 changes: 3 additions & 0 deletions importexport/musicxml/musicxml.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ class SlurDesc {
State _state;
};

// Ties are identified by the pitch and track of their first note
typedef std::pair<int, int> TieLocation;

//---------------------------------------------------------
// MusicXml
//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2255,7 +2255,7 @@ void Score::deleteMeasures(MeasureBase* is, MeasureBase* ie, bool preserveTies)
size_t track = staffIdx * VOICES;
if (track < s->elist().size()) {
TimeSig* nts = new TimeSig(score);
nts->setTrack(track);
nts->setTrack(static_cast<int>(track));
nts->setParent(s);
nts->setSig(lastDeletedForThisStaff->sig());
nts->setStretch(nts->sig() / mAfterSel->timesig());
Expand Down
6 changes: 3 additions & 3 deletions mscore/shortcutcapturedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ void ShortcutCaptureDialog::keyPress(QKeyEvent* e)
);
}

bool ShortcutCaptureDialog::isShiftAllowed(int key)
bool ShortcutCaptureDialog::isShiftAllowed(int k)
{
// Letter keys where Shift should not be removed
if (key >= Qt::Key_A && key <= Qt::Key_Z) {
if (k >= Qt::Key_A && k <= Qt::Key_Z) {
return true;
}

// non-letter keys where Shift should not be removed
switch (key) {
switch (k) {
case Qt::Key_Up:
case Qt::Key_Down:
case Qt::Key_Left:
Expand Down
Loading

0 comments on commit 089ef5b

Please sign in to comment.