Avoid nesting in parsing/error handling code

This commit is contained in:
Martchus 2021-02-02 15:05:45 +01:00
parent 82d0834e75
commit 16c1d96a28
1 changed files with 105 additions and 105 deletions

View File

@ -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);
@ -1005,7 +1006,6 @@ void TagEditorWidget::showFile(char result)
updateFileStatusStatus();
emit statusMessage(tr("The file %1 has been opened.").arg(m_currentPath));
emit fileShown();
}
}
/*!