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

let GUI::ExamplesFactory::itemizeSample fully set the sample item

parent 464a8438
No related branches found
No related tags found
1 merge request!2662Fix pointer abuse in jobs set view (#1005); fix handling of some exceptions
......@@ -15,6 +15,7 @@
#include "GUI/Model/FromCore/GUIExamplesFactory.h"
#include "Base/Util/Assert.h"
#include "GUI/Model/FromCore/ItemizeSample.h"
#include "GUI/Model/Sample/SampleItem.h"
#include "Sample/StandardSample/ExemplarySamples.h"
#include <QMap>
......@@ -66,9 +67,13 @@ bool GUI::ExamplesFactory::isValidExampleName(const QString& name)
SampleItem* GUI::ExamplesFactory::itemizeSample(const QString& name)
{
ASSERT(isValidExampleName(name));
MultiLayer* sample = std::get<2>(builders[name])();
auto [title, description, builder] = builders[name];
MultiLayer* sample = builder();
ASSERT(sample);
return GUI::FromCore::itemizeSample(*sample, name);
SampleItem* result = GUI::FromCore::itemizeSample(*sample, name);
result->setName(title);
result->setDescription(description);
return result;
}
QStringList GUI::ExamplesFactory::exampleNames()
......
......@@ -166,12 +166,10 @@ void SampleView::createActions(QToolBar* toolbar)
auto icon = QIcon(":/images/sample_layers2.png");
auto* action = import_menu->addAction(icon, title);
action->setToolTip(description);
connect(action, &QAction::triggered, [this, exampleName, title, description] {
connect(action, &QAction::triggered, [this, exampleName] {
try {
SampleItem* t = GUI::ExamplesFactory::itemizeSample(exampleName);
ASSERT(t);
t->setName(title);
t->setDescription(description);
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