Permalink
Browse files

Merge pull request #250 from inviwo/feature/exception2

Feature/exception2
  • Loading branch information...
petersteneteg committed Sep 21, 2018
2 parents 81a2c3d + 50b76a9 commit ff275adecee2e937a3301318d9fc536e638b3607
View
@@ -1,5 +1,14 @@
Here we document changes that affect the public API or changes that needs to be communicated to other developers.
## 2018-09-21
Settings are no longer shared between executables. I.e. The Inviwo app and the integration test will not use the same settings any more. We now prefix the settings with the InviwoApplication display name. This also implies that any existing Inviwo app settings will be lost. To keep old setting one can prefix all the ".ivs" file in the inviwo settings folder with "Inviwo_". On windows the inviwo settings can be found in %APPDATA%/inviwo.
Added System settings for breaking into the debugger on various log message levels, and on throwing exceptions. Also added an option to add stacktraces to exceptions. All to help with debugging.
The inviwo app will now catch uncaught inviwo exceptions in main and present an dialog with information and an option to continue or abort. It will also give an option to save your workspace before closing.
InviwoApplicationQt now has the same order of constructor arguments as InviwoApplication.
## 2018-08-21
The property class identifier system no longer uses the `InviwoPropertyInfo` / `PropertyClassIdentifier` macros but rather implements
```
View
@@ -35,12 +35,15 @@
#include <inviwo/core/util/logerrorcounter.h>
#include <inviwo/core/util/raiiutils.h>
#include <inviwo/core/network/processornetwork.h>
#include <inviwo/core/util/raiiutils.h>
#include <inviwo/core/util/ostreamjoiner.h>
#include <inviwo/qt/editor/inviwomainwindow.h>
#include <inviwo/core/util/filelogger.h>
#include "inviwosplashscreen.h"
#include <moduleregistration.h>
#include <sstream>
#include <algorithm>
#include <warn/push>
#include <warn/ignore/all>
#include <QFile>
@@ -52,7 +55,7 @@ int main(int argc, char** argv) {
inviwo::LogCentral::init(&logger);
auto logCounter = std::make_shared<inviwo::LogErrorCounter>();
logger.registerLogger(logCounter);
inviwo::InviwoApplicationQt inviwoApp("Inviwo", argc, argv);
inviwo::InviwoApplicationQt inviwoApp(argc, argv, "Inviwo");
inviwoApp.setWindowIcon(QIcon(":/inviwo/inviwo_light.png"));
inviwoApp.setAttribute(Qt::AA_NativeWindows);
QFile styleSheetFile(":/stylesheets/inviwo.qss");
@@ -107,21 +110,61 @@ int main(int argc, char** argv) {
logCounter.reset();
// process last arguments
if (!clp.getQuitApplicationAfterStartup()) {
if (clp.getQuitApplicationAfterStartup()) {
mainWin.exitInviwo(false);
return 0;
}
while (true) {
try {
return inviwoApp.exec();
} catch (const inviwo::Exception& e) {
inviwo::util::log(e.getContext(), e.getMessage());
QMessageBox::critical(nullptr, "Fatal Error", QString::fromStdString(e.getMessage()));
{
inviwo::util::log(e.getContext(), e.getMessage());
std::stringstream ss;
auto j = inviwo::util::make_ostream_joiner(ss, "\n");
std::copy(e.getStack().begin(), e.getStack().end(), j);
LogErrorCustom("Inviwo", ss.str());
}
{
std::stringstream ss;
ss << e.getMessage();
if (!e.getStack().empty()) {
ss << "\nStack Trace:\n";
auto j = inviwo::util::make_ostream_joiner(ss, "\n");
if (std::distance(e.getStack().begin(), e.getStack().end()) > 10) {
std::copy(e.getStack().begin(), e.getStack().begin() + 10, j);
ss << "\n...";
} else {
std::copy(e.getStack().begin(), e.getStack().end(), j);
}
}
ss << "\nApplication state might be corrupted, be warned.";
auto res = QMessageBox::critical(
&mainWin, "Fatal Error", QString::fromStdString(ss.str()),
QMessageBox::Ignore | QMessageBox::Close, QMessageBox::Close);
if (res == QMessageBox::Close) {
mainWin.askToSaveWorkspaceChanges();
return 1;
}
}
} catch (const std::exception& e) {
LogErrorCustom("inviwo.cpp", e.what());
QMessageBox::critical(nullptr, "Fatal Error", e.what());
LogErrorCustom("Inviwo", e.what());
std::stringstream ss;
ss << e.what();
ss << "\nApplication state might be corrupted, be warned.";
auto res =
QMessageBox::critical(&mainWin, "Fatal Error", QString::fromStdString(ss.str()),
QMessageBox::Ignore | QMessageBox::Close, QMessageBox::Close);
if (res == QMessageBox::Close) {
mainWin.askToSaveWorkspaceChanges();
return 1;
}
} catch (...) {
LogErrorCustom("inviwo.cpp", "Uncaught exception, terminating");
LogErrorCustom("Inviwo", "Uncaught exception, terminating");
QMessageBox::critical(nullptr, "Fatal Error", "Uncaught exception, terminating");
return 1;
}
} else {
mainWin.exitInviwo(false);
return 0;
}
}
@@ -56,7 +56,7 @@ int main(int argc, char** argv) {
auto logger = std::make_shared<inviwo::ConsoleLogger>();
LogCentral::getPtr()->registerLogger(logger);
InviwoApplication inviwoApp(argc, argv, "Inviwo v" + IVW_VERSION + " - GLFWApp");
InviwoApplication inviwoApp(argc, argv, "Inviwo-GLFW");
inviwoApp.printApplicationInfo();
inviwoApp.setPostEnqueueFront([]() { glfwPostEmptyEvent(); });
inviwoApp.setProgressCallback([](std::string m) {
@@ -49,8 +49,7 @@ int main(int argc, char** argv) {
auto logger = std::make_shared<inviwo::ConsoleLogger>();
LogCentral::getPtr()->registerLogger(logger);
std::string appName = "Inviwo v" + IVW_VERSION + " - QtApp";
InviwoApplicationQt inviwoApp(appName, argc, argv);
InviwoApplicationQt inviwoApp(argc, argv, "Inviwo-Qt");
inviwoApp.printApplicationInfo();
inviwoApp.setAttribute(Qt::AA_NativeWindows);
inviwoApp.setProgressCallback([](std::string m) {
Oops, something went wrong.

0 comments on commit ff275ad

Please sign in to comment.