diff --git a/GUI/View/Sample/SampleEditor.cpp b/GUI/View/Sample/SampleEditor.cpp index c4a9aedcf4453fdc28dcb7b5122a26f79c126b2c..0eb7c02c7bfc8fa8354bd67ed5776d0c3cfb318d 100644 --- a/GUI/View/Sample/SampleEditor.cpp +++ b/GUI/View/Sample/SampleEditor.cpp @@ -33,16 +33,11 @@ SampleEditor::SampleEditor() SampleEditor::~SampleEditor() { - qDeleteAll(m_edit_controllers.values()); } void SampleEditor::setCurrentSample(SampleItem* sampleItem) { - if (m_current_sample != nullptr) - m_edit_controllers[m_current_sample]->setSampleForm(nullptr); - m_current_sample_widget = nullptr; - delete QScrollArea::takeWidget(); m_current_sample = sampleItem; if (m_current_sample == nullptr) { @@ -50,9 +45,8 @@ void SampleEditor::setCurrentSample(SampleItem* sampleItem) return; } - if (!m_edit_controllers.contains(m_current_sample)) - m_edit_controllers.insert(m_current_sample, new SampleEditorController(m_current_sample)); - auto* ec = m_edit_controllers[m_current_sample]; + m_edit_controller = std::make_unique<SampleEditorController>(m_current_sample); + auto* ec = m_edit_controller.get(); connect(ec, &SampleEditorController::requestViewInRealspace, this, &SampleEditor::requestViewInRealspace); connect(ec, &SampleEditorController::aboutToRemoveItem, this, &SampleEditor::aboutToRemoveItem); diff --git a/GUI/View/Sample/SampleEditor.h b/GUI/View/Sample/SampleEditor.h index ab970543384f28571e9e7acee017aea6e8652016..4cad7280da922b9bb017ef248c88c6fc6e603c4a 100644 --- a/GUI/View/Sample/SampleEditor.h +++ b/GUI/View/Sample/SampleEditor.h @@ -15,8 +15,8 @@ #ifndef BORNAGAIN_GUI_VIEW_SAMPLE_SAMPLEEDITOR_H #define BORNAGAIN_GUI_VIEW_SAMPLE_SAMPLEEDITOR_H -#include <QMap> #include <QScrollArea> +#include <memory> class Item3D; class SampleEditorController; @@ -40,7 +40,7 @@ signals: private: SampleForm* m_current_sample_widget; SampleItem* m_current_sample = nullptr; - QMap<SampleItem*, SampleEditorController*> m_edit_controllers; + std::unique_ptr<SampleEditorController> m_edit_controller; };