Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GH#24998: cannot use shortcut (show-corrupted-measures) #25011

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Jojo-Schmitz
Copy link
Contributor

Resolves: #24998

@Jojo-Schmitz Jojo-Schmitz force-pushed the show-corrupted-measures branch from 3a3129b to cfc9792 Compare October 2, 2024 11:08
@Jojo-Schmitz Jojo-Schmitz force-pushed the show-corrupted-measures branch 2 times, most recently from 4abdf23 to 6ba7955 Compare October 2, 2024 18:52
@Jojo-Schmitz Jojo-Schmitz force-pushed the show-corrupted-measures branch from 6ba7955 to fdb875e Compare October 2, 2024 20:27
@Jojo-Schmitz
Copy link
Contributor Author

Anything still for me to do on this one?

@cbjeukendrup
Copy link
Contributor

Not everything from #25011 (comment) has been addressed yet.

  • Adding the "check for corruptions" command could be done in a follow-up PR
  • perhaps decoupling corruption checking from autosave too
  • but the mentioned optimisation would still be nice to make; it's not an optimisation for checking, but an optimisation for drawing. If we can see that the score has currently no known corrupted measures, by reading just one bool, that's a nice optimisation compared to always iterating over all measures on a page.
    Implementation: add a getter/setter hasCorruptedMeasures in Score, false by default; in the corruption checking method, reset it to false at the beginning, and as soon as any corrupted measure is found, set it to true; in the drawing code, read the value before undertaking any iteration through measures.

@Jojo-Schmitz
Copy link
Contributor Author

Jojo-Schmitz commented Nov 8, 2024

Such an optimization would mean: if it has been detected to be corrupt once, there's no need to check again, unless that corruption got fixed meanwhile, whoch could have happened only if it got modified since the last check.
But if there were no corruptions on last check, it would need to get checked again, if the score got changed meanwhile, wouldn't it?
So if the score got changed, we need to check for corruptions (old ones that got fix, new ones that crept it), else we don't, And for that we could use the existing getter Score::dirty(), couldn't we?

Hmm, maybe not. Maybe I'm over-thinking this. Initialize a new m_corrupt to false, set to false right before checking in sanityCheckLocal(), set to true if any of the checks fails, check whether set in paintPageDebug() together with the check for showCorruptedMeasures, reset to ' false' on next check, should that succeed (rather than rechecking on next change).

That in turn seems to ask for another menu entry to trigger a recheck and with that fullfill your 1st point.

Your 2nd point, disabling the sanity check on autosave, seems quite easy to do too.

See what I've done now...

@Jojo-Schmitz Jojo-Schmitz force-pushed the show-corrupted-measures branch 6 times, most recently from 5a32d9f to a9b1394 Compare November 8, 2024 20:29
@Jojo-Schmitz
Copy link
Contributor Author

Anything else I'd need to do on this?

@Jojo-Schmitz Jojo-Schmitz force-pushed the show-corrupted-measures branch from a9b1394 to 6f5e4ba Compare December 1, 2024 17:48
@@ -457,7 +457,8 @@ MenuItem* AppMenuModel::makeDiagnosticsMenu()
makeMenuItem("color-segment-shapes"),
makeMenuItem("show-skylines"),
makeMenuItem("show-system-bounding-rects"),
makeMenuItem("show-corrupted-measures")
makeMenuItem("show-corrupted-measures"),
makeMenuItem("check-sanity")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would now only be available in dev mode, while it would be useful in normal mode too. Let's make the Diagnostics > Engraving menu available in normal mode too; in normal mode, it should only contain the show-corrupted-measures and check-sanity actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (globalConfiguration()->devModeEnabled()) {
   // show all those submenus, including the full version of the Engraving submenu
} else {
    // show only an Engraving submenu, that contains only `show-corrupted-measures` and `check-for-score-corruptions
}

@cbjeukendrup
Copy link
Contributor

Also, do we actually register a handle for the new check-sanity / check-for-score-corruptions action anywhere? It looks like it would currently be non-functional...

@Jojo-Schmitz Jojo-Schmitz force-pushed the show-corrupted-measures branch from 67d0940 to 5fef69e Compare December 1, 2024 18:02
@Jojo-Schmitz
Copy link
Contributor Author

You lost me, I'm affraid, register what, where, why?

@cbjeukendrup
Copy link
Contributor

With the UiAction, we register the UI details of the action (name, icon, context, etc.). But what should happen when executing the action, is defined by registering a handler for it, for example in notationactioncontroller.cpp.

What you'd need to do concretely, is:

  • In NotationActionController, create a new method checkForScoreCorruptions()
  • At the bottom of NotationActionController::init(), add
        dispatcher()->reg(this, "check-for-score-corruptions", [this] { checkForScoreCorruptions(); });

This means, that whenever the check-for-score-corruptions action is triggered, the new checkForScoreCorruptions() method is called.

For implementing this method, you could call currentMasterNotation()->masterScore()->sanityCheck(); and then based on that, show an error dialog, based on ProjectActionsController::askIfUserAgreesToOpenCorruptedProject.

@Jojo-Schmitz
Copy link
Contributor Author

Isn't that done already in

    // Register engraving debugging options actions
    for (auto& [code, member] : engravingDebuggingActions) {
        dispatcher()->reg(this, code, [this, member = member]() {
            EngravingDebuggingOptions options = engravingConfiguration()->debuggingOptions();
            options.*member = !(options.*member);
            engravingConfiguration()->setDebuggingOptions(options);
        });
    }

@cbjeukendrup
Copy link
Contributor

For show-corrupted-measures yes, but for check-for-score-corruptions no (see also the definition of engravingDebuggingActions)

@Jojo-Schmitz
Copy link
Contributor Author

Jojo-Schmitz commented Dec 1, 2024

As by that time the score is open already, there's no point in asking whether or not to open the score anyway.
Not even any OK/Cancel makes sense here.

But I guess you lost me completly here...

@cbjeukendrup
Copy link
Contributor

Indeed, it would be only an OK button in this case.

So, the idea is, this new "Check for score corruptors" command would call sanityCheck, and if there are any corruptions, report those to the user, similarly to how they are reported when opening a corrupted file, except that of course any other button than OK and "Show details" wouldn't make sense here.

What we could additionally do, is showing an info dialog when the score is not corrupted.

@Jojo-Schmitz Jojo-Schmitz force-pushed the show-corrupted-measures branch from 5fef69e to 9cff3f3 Compare December 3, 2024 15:40
@Jojo-Schmitz Jojo-Schmitz force-pushed the show-corrupted-measures branch 2 times, most recently from c4685e3 to 1412c23 Compare December 4, 2024 10:40
@Jojo-Schmitz
Copy link
Contributor Author

Like this?

@Jojo-Schmitz Jojo-Schmitz force-pushed the show-corrupted-measures branch from 1412c23 to 2443074 Compare December 4, 2024 10:43
@Jojo-Schmitz Jojo-Schmitz force-pushed the show-corrupted-measures branch from 2443074 to 8f2befb Compare February 19, 2025 15:26
@Jojo-Schmitz
Copy link
Contributor Author

Rebased to resolve a merge conflict. Please review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cannot use shortcut (show-corrupted-measures)
2 participants