Skip to content

Commit

Permalink
OPTIMIZATION: Remove unnecessary calls to triggerLayoutAll
Browse files Browse the repository at this point in the history
Backport of  musescore#20141
  • Loading branch information
mike-spa authored and Jojo-Schmitz committed Nov 23, 2023
1 parent be80549 commit 1d5b021
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 30 deletions.
8 changes: 6 additions & 2 deletions libmscore/element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1911,9 +1911,13 @@ void Element::triggerLayout() const
score()->setLayout(tick(), staffIdx(), this);
}

//---------------------------------------------------------
//----------------------------------------------------------------------
// triggerLayoutAll
//---------------------------------------------------------
//
// *************************** CAUTION *******************************
// This causes a layout of the entire score: extremely expensive and
// likely unnecessary! Consider overriding triggerLayout() instead.
//----------------------------------------------------------------------

void Element::triggerLayoutAll() const
{
Expand Down
2 changes: 1 addition & 1 deletion libmscore/figuredbass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ bool FiguredBassItem::setProperty(Pid propertyId, const QVariant& v)
default:
return Element::setProperty(propertyId, v);
}
triggerLayoutAll();
triggerLayout();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion libmscore/glissando.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ bool Glissando::setProperty(Pid propertyId, const QVariant& v)
return false;
break;
}
triggerLayoutAll();
triggerLayout();
return true;
}

Expand Down
5 changes: 4 additions & 1 deletion libmscore/layoutbreak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "score.h"
#include "mscore.h"
#include "xml.h"
#include "measurebase.h"

namespace Ms {

Expand Down Expand Up @@ -290,7 +291,9 @@ bool LayoutBreak::setProperty(Pid propertyId, const QVariant& v)
return false;
break;
}
triggerLayoutAll();
triggerLayout();
if (parent() && measure()->next())
measure()->next()->triggerLayout();
setGenerated(false);
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion libmscore/lyrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,9 @@ Element* Lyrics::drop(EditData& data)
void Lyrics::endEdit(EditData& ed)
{
TextBase::endEdit(ed);
triggerLayoutAll();
triggerLayout();
if (_separator)
_separator->triggerLayout();
}

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion libmscore/lyricsline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ bool LyricsLine::setProperty(Pid propertyId, const QVariant& v)
return false;
break;
}
triggerLayoutAll();
triggerLayout();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion libmscore/marker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ bool Marker::setProperty(Pid propertyId, const QVariant& v)
return false;
break;
}
triggerLayoutAll();
triggerLayout();
return true;
}

Expand Down
12 changes: 7 additions & 5 deletions libmscore/measurebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ void MeasureBase::add(Element* e)
setLineBreak(false);
setSectionBreak(true);
setNoBreak(false);
//does not work with repeats: score()->tempomap()->setPause(endTick(), b->pause());
triggerLayoutAll();
break;
case LayoutBreak::NOBREAK:
setPageBreak(false);
Expand All @@ -154,7 +152,6 @@ void MeasureBase::add(Element* e)
}
if (next())
next()->triggerLayout();
// triggerLayoutAll(); // TODO
}
triggerLayout();
_el.push_back(e);
Expand All @@ -179,16 +176,21 @@ void MeasureBase::remove(Element* el)
case LayoutBreak::SECTION:
setSectionBreak(false);
score()->setPause(endTick(), 0);
triggerLayoutAll();
triggerLayout();
break;
case LayoutBreak::NOBREAK:
setNoBreak(false);
break;
}
}

if (!_el.remove(el)) {
qDebug("MeasureBase(%p)::remove(%s,%p) not found", this, el->name(), el);
}

triggerLayout();
if (next())
next()->triggerLayout();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -423,7 +425,7 @@ bool MeasureBase::setProperty(Pid id, const QVariant& value)
return false;
break;
}
triggerLayoutAll();
triggerLayout();
score()->setPlaylistDirty();
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions libmscore/slurtie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ bool SlurTieSegment::setProperty(Pid propertyId, const QVariant& v)
default:
return SpannerSegment::setProperty(propertyId, v);
}
triggerLayoutAll();
triggerLayout();
return true;
}

Expand Down Expand Up @@ -526,7 +526,7 @@ bool SlurTie::setProperty(Pid propertyId, const QVariant& v)
default:
return Spanner::setProperty(propertyId, v);
}
triggerLayoutAll();
triggerLayout();
return true;
}

Expand Down
12 changes: 1 addition & 11 deletions libmscore/spanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ bool SpannerSegment::setProperty(Pid pid, const QVariant& v)
switch (pid) {
case Pid::OFFSET2:
_offset2 = v.toPointF();
triggerLayoutAll();
triggerLayout();
break;
default:
return Element::setProperty(pid, v);
Expand Down Expand Up @@ -1119,16 +1119,6 @@ void Spanner::triggerLayout() const
score()->setLayout(_tick, _tick + _ticks, staffIdx(), track2staff(tr2), this);
}

void Spanner::triggerLayoutAll() const
{
// Spanners do not have parent even when added to a score, so can't check parent here
score()->setLayoutAll(staffIdx(), this);

const int tr2 = track2();
if (tr2 != -1 && tr2 != track())
score()->setLayoutAll(track2staff(tr2), this);
}

//---------------------------------------------------------
// pushUnusedSegment
//---------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion libmscore/spanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ class Spanner : public Element {
virtual void layoutSystemsDone();

virtual void triggerLayout() const override;
virtual void triggerLayoutAll() const override;
virtual void add(Element*) override;
virtual void remove(Element*) override;
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
Expand Down
2 changes: 1 addition & 1 deletion libmscore/tie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void TieSegment::changeAnchor(EditData& ed, Element* element)
score()->endCmd();
score()->startCmd();
ed.view->startEdit(newSegment, ed.curGrip);
triggerLayoutAll();
triggerLayout();
}
}

Expand Down
2 changes: 1 addition & 1 deletion libmscore/trill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ bool Trill::setProperty(Pid propertyId, const QVariant& val)
return false;
break;
}
triggerLayoutAll();
triggerLayout();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion libmscore/vibrato.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ bool Vibrato::setProperty(Pid propertyId, const QVariant& val)
return false;
break;
}
triggerLayoutAll();
triggerLayout();
return true;
}

Expand Down

0 comments on commit 1d5b021

Please sign in to comment.