Mercurial > hg > tony
diff src/MainWindow.cpp @ 314:2a2fd6eb8fa8
If user asks to save before initial analysis is complete, wait for it
author | Chris Cannam |
---|---|
date | Fri, 13 Jun 2014 12:12:27 +0100 |
parents | eef5c50e7e34 |
children | fd7bdb74c8ec 0862da97abc5 |
line wrap: on
line diff
--- a/src/MainWindow.cpp Fri Jun 13 10:37:04 2014 +0100 +++ b/src/MainWindow.cpp Fri Jun 13 12:12:27 2014 +0100 @@ -1780,6 +1780,34 @@ return false; } +bool +MainWindow::waitForInitialAnalysis() +{ + // Called before saving a session. We can't safely save while the + // initial analysis is happening, because then we end up with an + // incomplete session on reload. There are certainly theoretically + // better ways to handle this... + + if (!m_analyser || m_analyser->getInitialAnalysisCompletion() >= 100) { + return true; + } + + QMessageBox mb(QMessageBox::Information, + tr("Waiting for analysis"), + tr("Waiting for initial analysis to complete before saving..."), + QMessageBox::Cancel, + this); + + connect(m_analyser, SIGNAL(initialAnalysisCompleted()), + &mb, SLOT(accept())); + + if (mb.exec() == QDialog::Accepted) { + return true; + } else { + return false; + } +} + void MainWindow::saveSession() { @@ -1807,6 +1835,8 @@ { if (m_audioFile == "") return; + if (!waitForInitialAnalysis()) return; + // We do not want to save mid-analysis regions -- that would cause // confusion on reloading m_analyser->clearReAnalysis(); @@ -1835,6 +1865,11 @@ } } + if (!waitForInitialAnalysis()) { + QMessageBox::warning(this, tr("File not saved"), + tr("Wait cancelled: the session has not been saved.")); + } + if (!saveSessionFile(path)) { QMessageBox::critical(this, tr("Failed to save file"), tr("Session file \"%1\" could not be saved.").arg(path)); @@ -1863,6 +1898,12 @@ return; } + if (!waitForInitialAnalysis()) { + QMessageBox::warning(this, tr("File not saved"), + tr("Wait cancelled: the session has not been saved.")); + return; + } + if (!saveSessionFile(path)) { QMessageBox::critical(this, tr("Failed to save file"), tr("Session file \"%1\" could not be saved.").arg(path));