Skip to content

Commit

Permalink
fix #102571 Hang/crash by copy-paste all a system of linked staves co…
Browse files Browse the repository at this point in the history
…ntaining lines
  • Loading branch information
wschweer committed Dec 17, 2018
1 parent 64e1265 commit 264ce26
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 25 deletions.
5 changes: 4 additions & 1 deletion libmscore/edit.cpp
Expand Up @@ -4308,7 +4308,10 @@ void Score::undoAddElement(Element* element)
}
}
}
undo(new AddElement(nsp));
if (!alreadyInList(nsp))
undo(new AddElement(nsp));
else
qDebug("%s already there", nsp->name());
}
else if (et == ElementType::GLISSANDO)
undo(new AddElement(toSpanner(ne)));
Expand Down
9 changes: 9 additions & 0 deletions libmscore/score.cpp
Expand Up @@ -3585,6 +3585,15 @@ void Score::addSpanner(Spanner* s)
_spanner.addSpanner(s);
}

//---------------------------------------------------------
// alreadyInList
//---------------------------------------------------------

bool Score::alreadyInList(Spanner* s) const
{
return _spanner.alreadyInList(s);
}

//---------------------------------------------------------
// removeSpanner
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/score.h
Expand Up @@ -1090,6 +1090,7 @@ class Score : public QObject, public ScoreElement {
bool isSpannerStartEnd(int tick, int track) const;
void removeSpanner(Spanner*);
void addSpanner(Spanner*);
bool alreadyInList(Spanner*) const;
void cmdAddSpanner(Spanner* spanner, const QPointF& pos);
void cmdAddSpanner(Spanner* spanner, int staffIdx, Segment* startSegment, Segment* endSegment);
void checkSpanner(int startTick, int lastTick);
Expand Down
27 changes: 19 additions & 8 deletions libmscore/spannermap.cpp
Expand Up @@ -71,20 +71,31 @@ const std::vector<Interval<Spanner*>>& SpannerMap::findOverlapping(int start, in

void SpannerMap::addSpanner(Spanner* s)
{
#if 0
#ifndef NDEBUG
// check if spanner already in list
for (auto i = begin(); i != end(); ++i) {
if (i->second == s) {
qFatal("SpannerMap::addSpanner: %s already in list %p", s->name(), s);
}
}
#endif
if (alreadyInList(s))
abort();
#endif
insert(std::pair<int,Spanner*>(s->tick(), s));
dirty = true;
}

//---------------------------------------------------------
// alreadyInList
//---------------------------------------------------------

bool SpannerMap::alreadyInList(Spanner* s) const
{
for (auto i = begin(); i != end(); ++i) {
Spanner* os = i->second;
if (os->type() == s->type()) {
if (os->tick() == s->tick() && os->tick2() == s->tick2()
&& os->track() == s->track() && os->track2() == s->track2())
return true;
}
}
return false;
}

//---------------------------------------------------------
// removeSpanner
//---------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions libmscore/spannermap.h
Expand Up @@ -42,6 +42,8 @@ class SpannerMap : std::multimap<int, Spanner*> {
bool removeSpanner(Spanner* s);
void update() const;
void setDirty() const { dirty = true; } // must be called if a spanner changes start/length
bool alreadyInList(Spanner* s) const;

#ifndef NDEBUG
void dump() const;
#endif
Expand Down
32 changes: 16 additions & 16 deletions mscore/musescore.cpp
Expand Up @@ -125,7 +125,7 @@
#elif defined(MAC_SPARKLE_ENABLED)
#include "sparkle/sparkleAutoUpdater.h"
#endif

#ifdef USE_LAME
#include "exportmp3.h"
#endif
Expand Down Expand Up @@ -1630,13 +1630,13 @@ MuseScore::MuseScore()
for (auto i : { "voice-x12", "voice-x13", "voice-x14", "voice-x23", "voice-x24", "voice-x34" })
menuVoices->addAction(getAction(i));
menuTools->addMenu(menuVoices);

menuMeasure = new QMenu("");
for (auto i : { "split-measure", "join-measures" })
menuMeasure->addAction(getAction(i));
menuTools->addMenu(menuMeasure);
menuTools->addAction(getAction("time-delete"));

menuTools->addSeparator();

menuTools->addAction(getAction("slash-fill"));
Expand Down Expand Up @@ -1888,7 +1888,7 @@ MuseScore::MuseScore()
#endif
connect(this, SIGNAL(musescoreWindowWasShown()), this, SLOT(checkForUpdates()),
Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection));

if (!converterMode && !pluginMode)
_loginManager = new LoginManager(getAction(saveOnlineMenuItem), this);
}
Expand Down Expand Up @@ -3808,8 +3808,8 @@ void MuseScore::clipboardChanged()

void MuseScore::inputMethodAnchorRectangleChanged()
{
QRectF r = QGuiApplication::inputMethod()->anchorRectangle();
qDebug("inputMethod AnchorRectangle Changed: (%f, %f) + (%f, %f)", r.x(), r.y(), r.width(), r.height());
// QRectF r = QGuiApplication::inputMethod()->anchorRectangle();
// qDebug("inputMethod AnchorRectangle Changed: (%f, %f) + (%f, %f)", r.x(), r.y(), r.width(), r.height());
}

//---------------------------------------------------------
Expand All @@ -3818,7 +3818,7 @@ void MuseScore::inputMethodAnchorRectangleChanged()

void MuseScore::inputMethodAnimatingChanged()
{
qDebug("inputMethod Animating Changed: %d", QGuiApplication::inputMethod()->isAnimating());
// qDebug("inputMethod Animating Changed: %d", QGuiApplication::inputMethod()->isAnimating());
}

//---------------------------------------------------------
Expand All @@ -3827,8 +3827,8 @@ void MuseScore::inputMethodAnimatingChanged()

void MuseScore::inputMethodCursorRectangleChanged()
{
QRectF r = QGuiApplication::inputMethod()->cursorRectangle();
qDebug("inputMethod CursorRectangle Changed: (%f, %f) + (%f, %f)", r.x(), r.y(), r.width(), r.height());
// QRectF r = QGuiApplication::inputMethod()->cursorRectangle();
// qDebug("inputMethod CursorRectangle Changed: (%f, %f) + (%f, %f)", r.x(), r.y(), r.width(), r.height());
}

//---------------------------------------------------------
Expand All @@ -3837,7 +3837,7 @@ void MuseScore::inputMethodCursorRectangleChanged()

void MuseScore::inputMethodInputDirectionChanged(Qt::LayoutDirection newDirection)
{
qDebug("inputMethod InputDirection Changed: (QLocale::LayoutDirection enum) #%d", newDirection);
// qDebug("inputMethod InputDirection Changed: (QLocale::LayoutDirection enum) #%d", newDirection);
}

//---------------------------------------------------------
Expand All @@ -3846,8 +3846,8 @@ void MuseScore::inputMethodInputDirectionChanged(Qt::LayoutDirection newDirectio

void MuseScore::inputMethodInputItemClipRectangleChanged()
{
QRectF r = QGuiApplication::inputMethod()->inputItemClipRectangle();
qDebug("inputMethod InputItemClipRectangle Changed: (%f, %f) + (%f, %f)", r.x(), r.y(), r.width(), r.height());
// QRectF r = QGuiApplication::inputMethod()->inputItemClipRectangle();
// qDebug("inputMethod InputItemClipRectangle Changed: (%f, %f) + (%f, %f)", r.x(), r.y(), r.width(), r.height());
}

//---------------------------------------------------------
Expand All @@ -3856,8 +3856,8 @@ void MuseScore::inputMethodInputItemClipRectangleChanged()

void MuseScore::inputMethodKeyboardRectangleChanged()
{
QRectF r = QGuiApplication::inputMethod()->keyboardRectangle();
qDebug("inputMethod KeyboardRectangle Changed: (%f, %f) + (%f, %f)", r.x(), r.y(), r.width(), r.height());
// QRectF r = QGuiApplication::inputMethod()->keyboardRectangle();
// qDebug("inputMethod KeyboardRectangle Changed: (%f, %f) + (%f, %f)", r.x(), r.y(), r.width(), r.height());
}

//---------------------------------------------------------
Expand All @@ -3866,7 +3866,7 @@ void MuseScore::inputMethodKeyboardRectangleChanged()

void MuseScore::inputMethodLocaleChanged()
{
qDebug("inputMethod Locale Changed: (QLocale::Script enum) #%d.", QGuiApplication::inputMethod()->locale().script());
// qDebug("inputMethod Locale Changed: (QLocale::Script enum) #%d.", QGuiApplication::inputMethod()->locale().script());
}

//---------------------------------------------------------
Expand All @@ -3875,7 +3875,7 @@ void MuseScore::inputMethodLocaleChanged()

void MuseScore::inputMethodVisibleChanged()
{
qDebug("inputMethodVisibleChanged: %d", QGuiApplication::inputMethod()->isVisible());
// qDebug("inputMethodVisibleChanged: %d", QGuiApplication::inputMethod()->isVisible());
}

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

0 comments on commit 264ce26

Please sign in to comment.