@@ -157,6 +157,13 @@ bool LayoutPanelTreeModel::removeRows(int row, int count, const QModelIndex& par
157157 return true ;
158158}
159159
160+ bool LayoutPanelTreeModel::shouldShowSystemObjectLayers () const
161+ {
162+ // Only show system object staves in master score
163+ // TODO: extend system object staves logic to parts
164+ return m_notation && m_notation->isMaster ();
165+ }
166+
160167void LayoutPanelTreeModel::initPartOrders ()
161168{
162169 m_sortedPartIdList.clear ();
@@ -305,7 +312,7 @@ void LayoutPanelTreeModel::setupNotationConnections()
305312
306313 m_notation->undoStack ()->changesChannel ().onReceive (this , [this ](const mu::engraving::ScoreChangesRange& changes) {
307314 if (!m_layoutPanelVisible) {
308- m_shouldUpdateSystemObjectLayers = true ;
315+ m_scoreChanged = true ;
309316 return ;
310317 }
311318
@@ -353,6 +360,8 @@ void LayoutPanelTreeModel::onScoreChanged(const mu::engraving::ScoreChangesRange
353360 for (AbstractLayoutPanelTreeItem* item : m_rootItem->childItems ()) {
354361 item->onScoreChanged (changes);
355362 }
363+
364+ m_scoreChanged = false ;
356365}
357366
358367void LayoutPanelTreeModel::clear ()
@@ -390,13 +399,16 @@ void LayoutPanelTreeModel::load()
390399 async::NotifyList<const Part*> masterParts = m_masterNotation->parts ()->partList ();
391400 sortParts (masterParts);
392401
402+ const bool showSystemObjectLayers = shouldShowSystemObjectLayers ();
393403 const std::vector<Staff*>& systemObjectStaves = m_masterNotation->notation ()->parts ()->systemObjectStaves ();
394- SystemObjectGroupsByStaff systemObjects = collectSystemObjectGroups (systemObjectStaves);
404+
405+ SystemObjectGroupsByStaff systemObjects;
406+ if (showSystemObjectLayers) {
407+ systemObjects = collectSystemObjectGroups (systemObjectStaves);
408+ }
395409
396410 for (const Part* part : masterParts) {
397- if (m_notation->isMaster ()) {
398- // Only show system object staves in master score
399- // TODO: extend system object staves logic to parts
411+ if (showSystemObjectLayers) {
400412 for (Staff* staff : part->staves ()) {
401413 if (muse::contains (systemObjectStaves, staff)) {
402414 m_rootItem->appendChild (buildSystemObjectsLayerItem (staff, systemObjects[staff]));
@@ -454,7 +466,12 @@ void LayoutPanelTreeModel::setLayoutPanelVisible(bool visible)
454466
455467 if (visible) {
456468 updateSelectedRows ();
457- updateSystemObjectLayers ();
469+
470+ if (m_scoreChanged) {
471+ onScoreChanged ();
472+ m_shouldUpdateSystemObjectLayers = true ;
473+ updateSystemObjectLayers ();
474+ }
458475 }
459476}
460477
@@ -1051,6 +1068,10 @@ void LayoutPanelTreeModel::updateSystemObjectLayers()
10511068 return ;
10521069 }
10531070
1071+ if (!shouldShowSystemObjectLayers ()) {
1072+ return ;
1073+ }
1074+
10541075 TRACEFUNC;
10551076
10561077 m_shouldUpdateSystemObjectLayers = false ;
0 commit comments