Avoid nesting in parsing/error handling code
This commit is contained in:
parent
82d0834e75
commit
16c1d96a28
|
@ -840,7 +840,6 @@ bool TagEditorWidget::startParsing(const QString &path, bool forceRefresh)
|
|||
// define function to parse the file
|
||||
const auto startThread = [this, &diag] {
|
||||
char result;
|
||||
try { // credits for this nesting go to GCC regression 66145
|
||||
try {
|
||||
// try to open with write access
|
||||
try {
|
||||
|
@ -859,8 +858,7 @@ bool TagEditorWidget::startParsing(const QString &path, bool forceRefresh)
|
|||
// the file could not be opened because an IO error occured
|
||||
m_fileInfo.close(); // ensure file is closed
|
||||
result = IoError;
|
||||
}
|
||||
} catch (const exception &e) {
|
||||
} catch (const std::exception &e) {
|
||||
diag.emplace_back(TagParser::DiagLevel::Critical, argsToString("Something completely unexpected happened: ", +e.what()), "parsing");
|
||||
result = FatalParsingError;
|
||||
} catch (...) {
|
||||
|
@ -904,6 +902,7 @@ bool TagEditorWidget::reparseFile()
|
|||
*/
|
||||
void TagEditorWidget::showFile(char result)
|
||||
{
|
||||
// handle IO errors
|
||||
if (result == IoError) {
|
||||
// update status
|
||||
updateFileStatusStatus();
|
||||
|
@ -916,7 +915,9 @@ void TagEditorWidget::showFile(char result)
|
|||
msgBox->setInformativeText(tr("Opening file: ") + m_currentPath);
|
||||
msgBox->show();
|
||||
emit statusMessage(statusMsg);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// load existing tags
|
||||
m_tags.clear();
|
||||
m_fileInfo.tags(m_tags);
|
||||
|
@ -1006,7 +1007,6 @@ void TagEditorWidget::showFile(char result)
|
|||
emit statusMessage(tr("The file %1 has been opened.").arg(m_currentPath));
|
||||
emit fileShown();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Invokes saving the current file and - if saving was successful loading the next file.
|
||||
|
|
Loading…
Reference in New Issue