From 8950ebb8aba7c8d10cb379b404b9d9c1cc672bb5 Mon Sep 17 00:00:00 2001 From: SeeLook <seelook@gmail.com> Date: Sun, 14 Aug 2016 15:32:52 +0200 Subject: [PATCH] Fixed crash when level with melodies was started from single note mode. Added missing condition for such a case, then moved hiding of melody button to TtoolBar::actionsToExam(), correctly set single mode state into global store, removed unused call of setSingleNoteMode from executor --- src/exam/texamexecutor.cpp | 6 +----- src/exam/tglobalexamstore.cpp | 12 ++++-------- src/gui/ttoolbar.cpp | 1 + src/mainwindow.cpp | 1 - 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/exam/texamexecutor.cpp b/src/exam/texamexecutor.cpp index f4460a9f5..6c925f6dc 100755 --- a/src/exam/texamexecutor.cpp +++ b/src/exam/texamexecutor.cpp @@ -163,10 +163,7 @@ TexamExecutor::TexamExecutor(MainWindow *mainW, QString examFile, Tlevel *lev) : TexecutorSupply::checkGuitarParamsChanged(mW, m_exam); // ---------- End of checking ---------------------------------- - if (m_exam->melodies()) - mW->setSingleNoteMode(false); - else - mW->setSingleNoteMode(true); + mW->setSingleNoteMode(!m_exam->melodies()); m_supp = new TexecutorSupply(&m_level, this); m_supp->createQuestionsList(m_questList); if (m_exam->melodies()) @@ -1011,7 +1008,6 @@ void TexamExecutor::prepareToExam() { m_glStore->storeSettings(); m_glStore->prepareGlobalsToExam(m_level); - mW->setSingleNoteMode(gl->S->isSingleNoteMode); mW->pitchView->setVisible(gl->L->soundViewEnabled); mW->guitar->setVisible(gl->L->guitarEnabled); mW->score->acceptSettings(); diff --git a/src/exam/tglobalexamstore.cpp b/src/exam/tglobalexamstore.cpp index bf9d27a65..d6f0b699a 100644 --- a/src/exam/tglobalexamstore.cpp +++ b/src/exam/tglobalexamstore.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2013-2014 by Tomasz Bojczuk * + * Copyright (C) 2013-2016 by Tomasz Bojczuk * * tomaszbojczuk@gmail.com * * * * This program is free software; you can redistribute it and/or modify * @@ -101,13 +101,9 @@ void TglobalExamStore::prepareGlobalsToExam(Tlevel& level) { m_globals->A->OUTenabled = true; } m_globals->A->intonation = level.intonation; - if (!level.canBeMelody()) - m_globals->S->isSingleNoteMode = true; - if (level.answerIsSound()) - m_globals->L->soundViewEnabled = true; - else - m_globals->L->soundViewEnabled = false; - if (level.canBeGuitar()) + m_globals->S->isSingleNoteMode = !level.canBeMelody(); + m_globals->L->soundViewEnabled = level.answerIsSound(); + if (level.canBeGuitar()) // enable guitar if necessary, but don't disable when it is visible m_globals->L->guitarEnabled = true; // change output instrument type when necessary (exam instrument differs from user) TODO // if (m_globals->instrument != e_noInstrument && m_globals->instrument != instrument) diff --git a/src/gui/ttoolbar.cpp b/src/gui/ttoolbar.cpp index b785dfda7..88fca40c4 100644 --- a/src/gui/ttoolbar.cpp +++ b/src/gui/ttoolbar.cpp @@ -173,6 +173,7 @@ void TtoolBar::actionsToExam() { checkAct->setIcon(QIcon(Tpath::img("check"))); checkAct->setShortcut(QKeySequence(Qt::Key_Return)); } + setMelodyButtonVisible(false); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 240bc2d7d..f1ae7c06b 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -542,7 +542,6 @@ void MainWindow::prepareToExam() { if (score->insertMode() != TmultiScore::e_single) { if (score->isScorePlayed()) m_melButt->playMelodySlot(); // stop playing when played - bar->setMelodyButtonVisible(false); } sound->stopPlaying(); examResults = new TexamView(); -- GitLab