9393#include " engraving/rw/xmlreader.h"
9494#include " engraving/rw/rwregister.h"
9595
96- #include " mscoreerrorscontroller.h"
9796#include " notationerrors.h"
9897#include " notation.h"
9998#include " notationnoteinput.h"
@@ -234,6 +233,8 @@ NotationInteraction::NotationInteraction(Notation* notation, INotationUndoStackP
234233 notifyAboutSelectionChangedIfNeed ();
235234 });
236235
236+ m_errorsController = std::make_shared<MScoreErrorsController>(iocContext ());
237+
237238 m_noteInput->stateChanged ().onNotify (this , [this ]() {
238239 if (!m_noteInput->isNoteInputMode ()) {
239240 hideShadowNote ();
@@ -1342,8 +1343,7 @@ void NotationInteraction::endDrag()
13421343 }
13431344
13441345 notifyAboutDragChanged ();
1345-
1346- MScoreErrorsController (iocContext ()).checkAndShowMScoreError ();
1346+ checkAndShowError ();
13471347}
13481348
13491349muse::async::Notification NotationInteraction::dragChanged () const
@@ -2047,7 +2047,7 @@ bool NotationInteraction::dropSingle(const PointF& pos, Qt::KeyboardModifiers mo
20472047 notifyAboutDropChanged ();
20482048 }
20492049
2050- MScoreErrorsController ( iocContext ()). checkAndShowMScoreError ();
2050+ checkAndShowError ();
20512051
20522052 return accepted;
20532053}
@@ -2172,7 +2172,7 @@ bool NotationInteraction::dropRange(const QByteArray& data, const PointF& pos, b
21722172 endDrop ();
21732173 notifyAboutDropChanged ();
21742174 // MScore::setError(MsError::DEST_TUPLET);
2175- // MScoreErrorsController(iocContext()).checkAndShowMScoreError ();
2175+ // checkAndShowError ();
21762176 // NOTE: if we show the error popup here it seems that the mouse-release event is missed
21772177 // so the dragged region stays sticked to the mouse and move around. Don't know how to fix it. [M.S.]
21782178 return false ;
@@ -2207,7 +2207,7 @@ bool NotationInteraction::dropRange(const QByteArray& data, const PointF& pos, b
22072207 endDrop ();
22082208 apply ();
22092209
2210- MScoreErrorsController ( iocContext ()). checkAndShowMScoreError ();
2210+ checkAndShowError ();
22112211
22122212 return true ;
22132213}
@@ -2336,7 +2336,7 @@ bool NotationInteraction::applyPaletteElement(mu::engraving::EngravingItem* elem
23362336
23372337 setDropTarget (nullptr );
23382338
2339- MScoreErrorsController ( iocContext ()). checkAndShowMScoreError ();
2339+ checkAndShowError ();
23402340
23412341 return true ;
23422342}
@@ -4909,7 +4909,7 @@ void NotationInteraction::splitSelectedMeasure()
49094909 score ()->cmdSplitMeasure (chordRest);
49104910 apply ();
49114911
4912- MScoreErrorsController ( iocContext ()). checkAndShowMScoreError ();
4912+ checkAndShowError ();
49134913}
49144914
49154915void NotationInteraction::joinSelectedMeasures ()
@@ -4924,7 +4924,7 @@ void NotationInteraction::joinSelectedMeasures()
49244924 score ()->cmdJoinMeasure (measureRange.startMeasure , measureRange.endMeasure );
49254925 apply ();
49264926
4927- MScoreErrorsController ( iocContext ()). checkAndShowMScoreError ();
4927+ checkAndShowError ();
49284928}
49294929
49304930Ret NotationInteraction::canAddBoxes () const
@@ -5116,6 +5116,7 @@ void NotationInteraction::addBoxes(BoxType boxType, int count, int beforeBoxInde
51165116void NotationInteraction::copySelection ()
51175117{
51185118 if (!selection ()->canCopy ()) {
5119+ checkAndShowError ();
51195120 return ;
51205121 }
51215122
@@ -5241,7 +5242,7 @@ void NotationInteraction::pasteSelection(const Fraction& scale)
52415242 selectAndStartEditIfNeeded (pastedElement);
52425243 }
52435244
5244- MScoreErrorsController ( iocContext ()). checkAndShowMScoreError ();
5245+ checkAndShowError ();
52455246}
52465247
52475248void NotationInteraction::swapSelection ()
@@ -5284,7 +5285,7 @@ void NotationInteraction::deleteSelection()
52845285 score ()->cmdDeleteSelection ();
52855286 }
52865287
5287- MScoreErrorsController ( iocContext ()). checkAndShowMScoreError ();
5288+ checkAndShowError ();
52885289 apply ();
52895290 resetHitElementContext ();
52905291}
@@ -5889,7 +5890,7 @@ void NotationInteraction::addIntervalToSelectedNotes(int interval)
58895890
58905891 if (notes.empty ()) {
58915892 MScore::setError (MsError::NO_NOTE_SELECTED);
5892- MScoreErrorsController ( iocContext ()). checkAndShowMScoreError ();
5893+ checkAndShowError ();
58935894 return ;
58945895 }
58955896
@@ -8201,3 +8202,11 @@ void NotationInteraction::setGetViewRectFunc(const std::function<RectF()>& func)
82018202{
82028203 static_cast <NotationNoteInput*>(m_noteInput.get ())->setGetViewRectFunc (func);
82038204}
8205+
8206+ void NotationInteraction::checkAndShowError ()
8207+ {
8208+ IF_ASSERT_FAILED (m_errorsController) {
8209+ return ;
8210+ }
8211+ m_errorsController->checkAndShowMScoreError ();
8212+ }
0 commit comments