Skip to content
Snippets Groups Projects
Commit ca513d63 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov Committed by Wuttke, Joachim
Browse files

handle exceptions from datafield saving thread

parent 6f3a0a49
No related branches found
No related tags found
2 merge requests!1528changes from r20.0,!1523Rethrow exceptions from datafield saving thread
Pipeline #93904 passed
......@@ -71,7 +71,7 @@ int main(int argc, char* argv[])
QString("Sorry, you encountered a fatal bug.\n"
"The application will terminate.\n"
"Please note the following and inform the maintainers.\n\n")
+ ex.what() + "\n",
+ ex.what() + "\n",
QMessageBox::Ok, nullptr);
msgbox.exec();
return 1;
......
......@@ -135,9 +135,18 @@ void DataItem::saveDatafield(const QString& projectDir) const
};
if (m_saveInBackground) {
auto* saveThread = QThread::create(saveLambda);
connect(saveThread, &QThread::finished, saveThread, &QObject::deleteLater);
saveThread->start();
std::string errorMessage;
auto* saveThread = new std::thread([&errorMessage, saveLambda]() {
try {
saveLambda();
} catch (const std::exception& ex) {
errorMessage = ex.what();
}
});
saveThread->join();
if (!errorMessage.empty())
throw std::runtime_error(errorMessage);
} else
saveLambda();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment