Handle unexpected exceptions when parsing/making
* Don't just ignore exception (previous behavior) * Add critical notification * Show results, though error (to ease debugging)
This commit is contained in:
parent
89d2da0191
commit
1924c1d804
|
@ -317,9 +317,9 @@ uint64 parseUInt64(const Argument &arg, uint64 defaultValue)
|
||||||
if(arg.isPresent()) {
|
if(arg.isPresent()) {
|
||||||
try {
|
try {
|
||||||
if(*arg.values().front() == '0' && *(arg.values().front() + 1) == 'x') {
|
if(*arg.values().front() == '0' && *(arg.values().front() + 1) == 'x') {
|
||||||
return stringToNumber<decltype(parseUInt64(arg, defaultValue))>(arg.values().front() + 2, 16);
|
return stringToNumber<uint64>(arg.values().front() + 2, 16);
|
||||||
} else {
|
} else {
|
||||||
return stringToNumber<decltype(parseUInt64(arg, defaultValue))>(arg.values().front());
|
return stringToNumber<uint64>(arg.values().front());
|
||||||
}
|
}
|
||||||
} catch(const ConversionException &) {
|
} catch(const ConversionException &) {
|
||||||
cerr << "Warning: The specified value \"" << arg.values().front() << "\" is no valid unsigned integer and will be ignored." << endl;
|
cerr << "Warning: The specified value \"" << arg.values().front() << "\" is no valid unsigned integer and will be ignored." << endl;
|
||||||
|
|
|
@ -752,26 +752,34 @@ bool TagEditorWidget::startParsing(const QString &path, bool forceRefresh)
|
||||||
auto startThread = [this] {
|
auto startThread = [this] {
|
||||||
m_fileOperationMutex.lock();
|
m_fileOperationMutex.lock();
|
||||||
char result;
|
char result;
|
||||||
try {
|
try { // credits for this nesting go to GCC regression 66145
|
||||||
try {
|
try {
|
||||||
// try to open with write access
|
try {
|
||||||
m_fileInfo.reopen(false);
|
// try to open with write access
|
||||||
|
m_fileInfo.reopen(false);
|
||||||
|
} catch(...) {
|
||||||
|
::IoUtilities::catchIoFailure();
|
||||||
|
// try to open read-only if opening with write access failed
|
||||||
|
m_fileInfo.reopen(true);
|
||||||
|
}
|
||||||
|
m_fileInfo.setForceFullParse(Settings::values().editor.forceFullParse);
|
||||||
|
m_fileInfo.parseEverything();
|
||||||
|
result = ParsingSuccessful;
|
||||||
|
} catch(const Failure &) {
|
||||||
|
// the file has been opened; parsing notifications will be shown in the info box
|
||||||
|
result = FatalParsingError;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
::IoUtilities::catchIoFailure();
|
::IoUtilities::catchIoFailure();
|
||||||
// try to open read-only if opening with write access failed
|
// the file could not be opened because an IO error occured
|
||||||
m_fileInfo.reopen(true);
|
m_fileInfo.close(); // ensure file is closed
|
||||||
|
result = IoError;
|
||||||
}
|
}
|
||||||
m_fileInfo.setForceFullParse(Settings::values().editor.forceFullParse);
|
} catch(const exception &e) {
|
||||||
m_fileInfo.parseEverything();
|
m_fileInfo.addNotification(Media::NotificationType::Critical, string("Something completely unexpected happened: ") + e.what(), "parsing");
|
||||||
result = ParsingSuccessful;
|
|
||||||
} catch(const Failure &) {
|
|
||||||
// the file has been opened; parsing notifications will be shown in the info box
|
|
||||||
result = FatalParsingError;
|
result = FatalParsingError;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
::IoUtilities::catchIoFailure();
|
m_fileInfo.addNotification(Media::NotificationType::Critical, "Something completely unexpected happened", "parsing");
|
||||||
// the file could not be opened because an IO error occured
|
result = FatalParsingError;
|
||||||
m_fileInfo.close(); // ensure file is closed
|
|
||||||
result = IoError;
|
|
||||||
}
|
}
|
||||||
m_fileInfo.unregisterAllCallbacks();
|
m_fileInfo.unregisterAllCallbacks();
|
||||||
QMetaObject::invokeMethod(this, "showFile", Qt::QueuedConnection, Q_ARG(char, result));
|
QMetaObject::invokeMethod(this, "showFile", Qt::QueuedConnection, Q_ARG(char, result));
|
||||||
|
@ -1080,12 +1088,20 @@ bool TagEditorWidget::startSaving()
|
||||||
m_fileOperationMutex.lock();
|
m_fileOperationMutex.lock();
|
||||||
bool processingError = false, ioError = false;
|
bool processingError = false, ioError = false;
|
||||||
try {
|
try {
|
||||||
m_fileInfo.applyChanges();
|
try {
|
||||||
} catch(const Failure &) {
|
m_fileInfo.applyChanges();
|
||||||
|
} catch(const Failure &) {
|
||||||
|
processingError = true;
|
||||||
|
} catch(...) {
|
||||||
|
::IoUtilities::catchIoFailure();
|
||||||
|
ioError = true;
|
||||||
|
}
|
||||||
|
} catch(const exception &e) {
|
||||||
|
m_fileInfo.addNotification(Media::NotificationType::Critical, string("Something completely unexpected happened: ") + e.what(), "making");
|
||||||
processingError = true;
|
processingError = true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
::IoUtilities::catchIoFailure();
|
m_fileInfo.addNotification(Media::NotificationType::Critical, "Something completely unexpected happened", "making");
|
||||||
ioError = true;
|
processingError = true;
|
||||||
}
|
}
|
||||||
m_fileInfo.unregisterAllCallbacks();
|
m_fileInfo.unregisterAllCallbacks();
|
||||||
QMetaObject::invokeMethod(this, "showSavingResult", Qt::QueuedConnection, Q_ARG(bool, processingError), Q_ARG(bool, ioError));
|
QMetaObject::invokeMethod(this, "showSavingResult", Qt::QueuedConnection, Q_ARG(bool, processingError), Q_ARG(bool, ioError));
|
||||||
|
|
Loading…
Reference in New Issue