Skip to content
Snippets Groups Projects
Commit 464a8438 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

catch exception from libff (to be ctd)

parent 896a79cf
No related branches found
No related tags found
1 merge request!2662Fix pointer abuse in jobs set view (#1005); fix handling of some exceptions
...@@ -67,7 +67,7 @@ SampleItem* GUI::ExamplesFactory::itemizeSample(const QString& name) ...@@ -67,7 +67,7 @@ SampleItem* GUI::ExamplesFactory::itemizeSample(const QString& name)
{ {
ASSERT(isValidExampleName(name)); ASSERT(isValidExampleName(name));
MultiLayer* sample = std::get<2>(builders[name])(); MultiLayer* sample = std::get<2>(builders[name])();
ASSERT(sample);
return GUI::FromCore::itemizeSample(*sample, name); return GUI::FromCore::itemizeSample(*sample, name);
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "GUI/Model/Sample/ParticleLayoutItem.h" #include "GUI/Model/Sample/ParticleLayoutItem.h"
#include "GUI/Model/Sample/SamplesSet.h" #include "GUI/Model/Sample/SamplesSet.h"
#include "GUI/View/Base/mainwindow_constants.h" #include "GUI/View/Base/mainwindow_constants.h"
#include "GUI/View/Info/MessageBox.h"
#include "GUI/View/IO/PythonImport.h" #include "GUI/View/IO/PythonImport.h"
#include "GUI/View/Modelview/SetView.h" #include "GUI/View/Modelview/SetView.h"
#include "GUI/View/Realspace/RealspacePanel.h" #include "GUI/View/Realspace/RealspacePanel.h"
...@@ -166,12 +167,15 @@ void SampleView::createActions(QToolBar* toolbar) ...@@ -166,12 +167,15 @@ void SampleView::createActions(QToolBar* toolbar)
auto* action = import_menu->addAction(icon, title); auto* action = import_menu->addAction(icon, title);
action->setToolTip(description); action->setToolTip(description);
connect(action, &QAction::triggered, [this, exampleName, title, description] { connect(action, &QAction::triggered, [this, exampleName, title, description] {
SampleItem* t = GUI::ExamplesFactory::itemizeSample(exampleName); try {
if (!t) SampleItem* t = GUI::ExamplesFactory::itemizeSample(exampleName);
return; ASSERT(t);
t->setName(title); t->setName(title);
t->setDescription(description); t->setDescription(description);
m_set->add_item(t); m_set->add_item(t);
} catch (const std::exception& ex) {
GUI::Message::warning("Cannot load exemplary sample", ex.what());
}
}); });
} }
......
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