Skip to content

Commit

Permalink
Add menu entry for sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
Jojo-Schmitz committed Feb 28, 2025
1 parent ca820ef commit 0f41f08
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/appshell/view/appmenumodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ MenuItem* AppMenuModel::makeDiagnosticsMenu()
makeMenuItem("show-skylines"),
makeMenuItem("show-system-bounding-rects"),
makeMenuItem("show-element-masks"),
makeMenuItem("show-corrupted-measures")
makeMenuItem("show-corrupted-measures"),
makeMenuItem("check-for-score-corruptions")
};

MenuItemList extensionsItems {
Expand Down
23 changes: 23 additions & 0 deletions src/notation/internal/notationactioncontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ const std::unordered_map<ActionCode, bool EngravingDebuggingOptions::*> Notation
{ "show-corrupted-measures", &EngravingDebuggingOptions::showCorruptedMeasures }
};

void NotationActionController::checkForScoreCorruptions()
{
String name = currentMasterNotation()->masterScore()->name();
Ret ret = currentMasterNotation()->masterScore()->sanityCheck();
if (ret) {
std::string title = muse::mtrc("project", "Score “%1” seems to be sane and healthy").arg(name).toStdString();
std::string body = muse::trc("project",
"This score does not seem to contain errors that could cause MuseScore Studio to malfunction.");

interactive()->info(title, body, {
interactive()->buttonData(IInteractive::Button::Ok) }).button();
} else {
std::string title = muse::mtrc("project", "Score “%1” is corrupted").arg(name).toStdString();
std::string body = muse::trc("project", "This score contains errors that could cause MuseScore Studio to malfunction.\n"
"Fix those at the earliest to prevent crashes and further corruptions.");

interactive()->warning(title, body, ret.text(), {
interactive()->buttonData(IInteractive::Button::Ok) }).button();
}
return;
}

void NotationActionController::init()
{
TRACEFUNC;
Expand Down Expand Up @@ -547,6 +569,7 @@ void NotationActionController::init()
engravingConfiguration()->setDebuggingOptions(options);
});
}
dispatcher()->reg(this, "check-for-score-corruptions", [this] { checkForScoreCorruptions(); });
}

bool NotationActionController::canReceiveAction(const ActionCode& code) const
Expand Down
2 changes: 2 additions & 0 deletions src/notation/internal/notationactioncontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class NotationActionController : public muse::actions::Actionable, public muse::
public:
void init();

void checkForScoreCorruptions();

bool canReceiveAction(const muse::actions::ActionCode& code) const override;

muse::async::Notification currentNotationChanged() const;
Expand Down
5 changes: 5 additions & 0 deletions src/notation/internal/notationuiactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2611,6 +2611,11 @@ const UiActionList NotationUiActions::m_engravingDebuggingActions = {
TranslatableString("action", "Show/hide corrupted measures"),
Checkable::Yes
),
UiAction("check-for-score-corruptions",
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "Check for score corruptions")
),
UiAction("edit-strings",
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED
Expand Down

0 comments on commit 0f41f08

Please sign in to comment.