Skip to content

Commit

Permalink
Fix GH#24998: cannot use shortcut (show-corrupted-measures)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jojo-Schmitz committed Dec 1, 2024
1 parent 7e2deed commit 3efede7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 20 deletions.
11 changes: 2 additions & 9 deletions src/engraving/dom/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Ret MasterScore::sanityCheck()
if (accumulatedErrors.empty()) {
return muse::make_ok();
}

setHasCorruptedMeasures(true);
return Ret(static_cast<int>(Err::FileCorrupted), accumulatedErrors);
}

Expand All @@ -150,6 +150,7 @@ Ret Score::sanityCheckLocal()
return muse::mtrc("engraving", "Part score: %1").arg(name());
};

setHasCorruptedMeasures(false);
for (Measure* m = firstMeasure(); m; m = m->nextMeasure()) {
Fraction mLen = m->ticks();
size_t endStaff = staves().size();
Expand All @@ -158,9 +159,7 @@ Ret Score::sanityCheckLocal()
Rest* fmrest0 = nullptr; // full measure rest in voice 0
Fraction voices[VOICES];

#ifndef NDEBUG
m->setCorrupted(staffIdx, false);
#endif

for (Segment* s = m->first(SegmentType::ChordRest); s; s = s->next(SegmentType::ChordRest)) {
for (voice_idx_t v = 0; v < VOICES; ++v) {
Expand Down Expand Up @@ -190,18 +189,14 @@ Ret Score::sanityCheckLocal()
if (!repeatsIsValid) {
errors << muse::mtrc("engraving", "<b>Corrupted measure</b>: %1, measure %2, staff %3.")
.arg(excerptInfo()).arg(mNumber).arg(staffIdx + 1);
#ifndef NDEBUG
m->setCorrupted(staffIdx, true);
#endif
}

if (voices[0] != mLen) {
//: %1 describes in which score the corruption is (either `Full score` or `"[part name]" part score`)
errors << muse::mtrc("engraving", "<b>Incomplete measure</b>: %1, measure %2, staff %3. Found: %4. Expected: %5.")
.arg(excerptInfo()).arg(mNumber).arg(staffIdx + 1).arg(voices[0].toString(), mLen.toString());
#ifndef NDEBUG
m->setCorrupted(staffIdx, true);
#endif
// try to fix a bad full measure rest
if (fmrest0) {
// fmrest0->setDuration(mLen * fmrest0->staff()->timeStretch(fmrest0->tick()));
Expand All @@ -214,9 +209,7 @@ Ret Score::sanityCheckLocal()
//: %1 describes in which score the corruption is (either `Full score` or `"[part name]" part score`)
errors << muse::mtrc("engraving", "<b>Voice too long</b>: %1, measure %2, staff %3, voice %4. Found: %5. Expected: %6.")
.arg(excerptInfo()).arg(mNumber).arg(staffIdx + 1).arg(v + 1).arg(voices[v].toString(), mLen.toString());
#ifndef NDEBUG
m->setCorrupted(staffIdx, true);
#endif
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/engraving/dom/measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ class MStaff
bool stemless() const { return m_stemless; }
void setStemless(bool val) { m_stemless = val; }

#ifndef NDEBUG
bool corrupted() const { return m_corrupted; }
void setCorrupted(bool val) { m_corrupted = val; }
#endif

int measureRepeatCount() const { return m_measureRepeatCount; }
void setMeasureRepeatCount(int n) { m_measureRepeatCount = n; }
Expand All @@ -125,9 +123,7 @@ class MStaff
// this changes some layout rules
bool m_visible = true;
bool m_stemless = false;
#ifndef NDEBUG
bool m_corrupted = false;
#endif
int m_measureRepeatCount = 0;
};

Expand Down Expand Up @@ -176,10 +172,8 @@ class Measure final : public MeasureBase
Spacer* vspacerUp(staff_idx_t staffIdx) const;
void setStaffVisible(staff_idx_t staffIdx, bool visible);
void setStaffStemless(staff_idx_t staffIdx, bool stemless);
#ifndef NDEBUG
bool corrupted(staff_idx_t staffIdx) const { return m_mstaves[staffIdx]->corrupted(); }
void setCorrupted(staff_idx_t staffIdx, bool val) { m_mstaves[staffIdx]->setCorrupted(val); }
#endif
MeasureNumber* noText(staff_idx_t staffIdx) const { return m_mstaves[staffIdx]->noText(); }
void setNoText(staff_idx_t staffIdx, MeasureNumber* t) { m_mstaves[staffIdx]->setNoText(t); }

Expand Down
3 changes: 3 additions & 0 deletions src/engraving/dom/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@ class Score : public EngravingObject, public muse::Injectable
void setPrinting(bool val) { m_printing = val; }
virtual bool playlistDirty() const;
virtual void setPlaylistDirty();
bool hasCorruptedMeasures() const { return m_corrupted; }
void setHasCorruptedMeasures(bool val) { m_corrupted = val; }

bool isOpen() const;
void setIsOpen(bool open);
Expand Down Expand Up @@ -1141,6 +1143,7 @@ class Score : public EngravingObject, public muse::Injectable
bool m_showInstrumentNames = true;
bool m_printing = false; // True if we are drawing to a printer
bool m_savedCapture = false; // True if we saved an image capture
bool m_corrupted = false;

ShowAnchors m_showAnchors;

Expand Down
2 changes: 0 additions & 2 deletions src/engraving/iengravingconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ class IEngravingConfiguration : MODULE_EXPORT_INTERFACE
|| colorSegmentShapes
|| showSkylines
|| showSystemBoundingRects
#ifndef NDEBUG
|| showCorruptedMeasures
#endif
;
}
};
Expand Down
4 changes: 1 addition & 3 deletions src/engraving/rendering/score/debugpaint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ void DebugPaint::paintPageDebug(Painter& painter, const Page* page, const std::v
}
}

#ifndef NDEBUG
if (options.showCorruptedMeasures) {
if (score->hasCorruptedMeasures() && options.showCorruptedMeasures) {
painter.setPen(Pen(Color::RED, 4.0));
painter.setBrush(BrushStyle::NoBrush);

Expand All @@ -256,7 +255,6 @@ void DebugPaint::paintPageDebug(Painter& painter, const Page* page, const std::v
}
}
}
#endif

painter.restore();
}
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 @@ -2550,6 +2550,7 @@ const UiActionList NotationUiActions::m_engravingDebuggingActions = {
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "Show element bounding rectangles"),
TranslatableString("action", "Show/hide element bounding rectangles"),
Checkable::Yes
),
UiAction("color-element-shapes",
Expand All @@ -2562,6 +2563,7 @@ const UiActionList NotationUiActions::m_engravingDebuggingActions = {
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "Show segment shapes"),
TranslatableString("action", "Show/hide segment shapes"),
Checkable::Yes
),
UiAction("color-segment-shapes",
Expand All @@ -2574,18 +2576,21 @@ const UiActionList NotationUiActions::m_engravingDebuggingActions = {
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "Show skylines"),
TranslatableString("action", "Show/hide skylines"),
Checkable::Yes
),
UiAction("show-system-bounding-rects",
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "Show system bounding rectangles"),
TranslatableString("action", "Show/hide system bounding rectangles"),
Checkable::Yes
),
UiAction("show-corrupted-measures",
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "Show corrupted measures"),
TranslatableString("action", "Show/hide corrupted measures"),
Checkable::Yes
),
UiAction("edit-strings",
Expand Down

0 comments on commit 3efede7

Please sign in to comment.