Skip to content

Commit

Permalink
Merge pull request #6106 from Spire42/305724-disable-save-prompt-for-…
Browse files Browse the repository at this point in the history
…empty-scores

Fix #305724: Disable save prompt for empty scores
  • Loading branch information
anatoly-os authored Jun 2, 2020
2 parents 4a053fc + a8d510a commit c7fb591
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ class Score : public QObject, public ScoreElement {
MStyle _style;

bool _created { false }; ///< file is never saved, has generated name
bool _startedEmpty { false }; ///< The score was created from an empty template (typically ":/data/My_First_Score.mscx") during this session, so it doesn't need to be saved if it hasn't been modified.
QString _tmpName; ///< auto saved with this name if not empty
QString _importedFilePath; // file from which the score was imported, or empty

Expand Down Expand Up @@ -853,6 +854,8 @@ class Score : public QObject, public ScoreElement {
ScoreContentState state() const;
void setCreated(bool val) { _created = val; }
bool created() const { return _created; }
void setStartedEmpty(bool val) { _startedEmpty = val; }
bool startedEmpty() const { return _startedEmpty; }
bool savedCapture() const { return _savedCapture; }
bool saved() const { return _saved; }
void setSaved(bool v) { _saved = v; }
Expand Down
2 changes: 1 addition & 1 deletion mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static bool readScoreError(const QString& name, Score::FileError error, bool ask

bool MuseScore::checkDirty(MasterScore* s)
{
if (s->dirty() || s->created()) {
if (s->dirty() || (s->created() && !s->startedEmpty())) {
QMessageBox::StandardButton n = QMessageBox::warning(this, tr("MuseScore"),
tr("Save changes to the score \"%1\"\n"
"before closing?").arg(s->fileInfo()->completeBaseName()),
Expand Down
10 changes: 5 additions & 5 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,14 @@ void MuseScore::closeEvent(QCloseEvent* ev)
unloadPlugins();
QList<MasterScore*> removeList;
for (MasterScore* score : scoreList) {
// Prompt the user to save the score if it's "dirty" (has unsaved changes) or if it's newly created.
// Prompt the user to save the score if it's "dirty" (has unsaved changes) or if it's newly created but non-empty.
if (checkDirty(score)) {
// The user has canceled out entirely, so ignore the close event.
ev->ignore();
return;
}
// If the score is still flagged as newly created at this point, it means that the user has just chosen to discard it,
// so we need to remove it from the list of scores to be saved to the session file.
// If the score is still flagged as newly created at this point, it means that either it's empty or the user has just
// chosen to discard it, so we need to remove it from the list of scores to be saved to the session file.
if (score->created())
removeList.append(score);
}
Expand Down Expand Up @@ -3491,7 +3491,7 @@ static void loadScores(const QStringList& argv)
score->setName(mscore->createDefaultName());
// TODO score->setPageFormat(*MScore::defaultStyle().pageFormat());
score->doLayout();
score->setCreated(true);
score->setStartedEmpty(true);
}
if (score == 0) {
score = mscore->readScore(":/data/My_First_Score.mscx");
Expand All @@ -3502,7 +3502,7 @@ static void loadScores(const QStringList& argv)
score->setName(mscore->createDefaultName());
// TODO score->setPageFormat(*MScore::defaultStyle().pageFormat());
score->doLayout();
score->setCreated(true);
score->setStartedEmpty(true);
}
}
if (score)
Expand Down

0 comments on commit c7fb591

Please sign in to comment.