From 0b47f6a3e286ebb8cfc799c7a0fd876d43085001 Mon Sep 17 00:00:00 2001
From: Samuel Jones <samjones714@gmail.com>
Date: Wed, 14 Aug 2019 11:27:21 +0100
Subject: [PATCH] Re #18826 Reinstate unique pointer IBatchPresenter in
 MainWindow

---
 .../ISISReflectometry/GUI/Batch/BatchPresenterFactory.h       | 4 ++--
 .../ISISReflectometry/GUI/Batch/IBatchPresenterFactory.h      | 2 +-
 .../ISISReflectometry/GUI/Common/Decoder.cpp                  | 4 ++--
 .../ISISReflectometry/GUI/Common/Encoder.cpp                  | 4 ++--
 .../ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h    | 2 +-
 .../test/ISISReflectometry/ReflMockObjects.h                  | 4 ++--
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenterFactory.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenterFactory.h
index a475849e0ab..f72b0cd91d2 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenterFactory.h
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenterFactory.h
@@ -37,7 +37,7 @@ public:
         m_instrumentPresenterFactory(std::move(instrumentPresenterFactory)),
         m_savePresenterFactory(std::move(savePresenterFactory)) {}
 
-  std::shared_ptr<IBatchPresenter> make(IBatchView *view) override {
+  std::unique_ptr<IBatchPresenter> make(IBatchView *view) override {
     auto runsPresenter = m_runsPresenterFactory.make(view->runs());
     auto eventPresenter = m_eventPresenterFactory.make(view->eventHandling());
     auto experimentPresenter =
@@ -50,7 +50,7 @@ public:
         experimentPresenter->experiment(), instrumentPresenter->instrument(),
         runsPresenter->mutableRunsTable(), eventPresenter->slicing());
 
-    return std::make_shared<BatchPresenter>(
+    return std::make_unique<BatchPresenter>(
         view, std::move(model), std::move(runsPresenter),
         std::move(eventPresenter), std::move(experimentPresenter),
         std::move(instrumentPresenter), std::move(savePresenter));
diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/IBatchPresenterFactory.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/IBatchPresenterFactory.h
index 3b15e50fba0..275de8fd54e 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/IBatchPresenterFactory.h
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/IBatchPresenterFactory.h
@@ -18,7 +18,7 @@ class IBatchView;
 class IBatchPresenterFactory {
 public:
   virtual ~IBatchPresenterFactory() = default;
-  virtual std::shared_ptr<IBatchPresenter> make(IBatchView *view) = 0;
+  virtual std::unique_ptr<IBatchPresenter> make(IBatchView *view) = 0;
 };
 } // namespace ISISReflectometry
 } // namespace CustomInterfaces
diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.cpp
index 7d50cee9c04..42369c090ce 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.cpp
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.cpp
@@ -17,9 +17,9 @@ namespace ISISReflectometry {
 BatchPresenter *Decoder::findBatchPresenter(const QtBatchView *gui,
                                             const QtMainWindowView &mwv) {
   for (auto &ipresenter : mwv.m_presenter->m_batchPresenters) {
-    auto presenter = std::dynamic_pointer_cast<BatchPresenter>(ipresenter);
+    auto presenter = dynamic_cast<BatchPresenter *>(ipresenter.get());
     if (presenter->m_view == gui) {
-      return presenter.get();
+      return presenter;
     }
   }
   return nullptr;
diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Encoder.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Encoder.cpp
index a6372082637..a15a8cac041 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Encoder.cpp
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Encoder.cpp
@@ -14,9 +14,9 @@ namespace ISISReflectometry {
 BatchPresenter *Encoder::findBatchPresenter(const QtBatchView *gui,
                                             const QtMainWindowView &mwv) {
   for (auto &ipresenter : mwv.m_presenter->m_batchPresenters) {
-    auto presenter = std::dynamic_pointer_cast<BatchPresenter>(ipresenter);
+    auto presenter = dynamic_cast<BatchPresenter *>(ipresenter.get());
     if (presenter->m_view == gui) {
-      return presenter.get();
+      return presenter;
     }
   }
   return nullptr;
diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h
index b95c2a5db95..76056df6fb2 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h
@@ -58,7 +58,7 @@ public:
 protected:
   IMainWindowView *m_view;
   IMessageHandler *m_messageHandler;
-  std::vector<std::shared_ptr<IBatchPresenter>> m_batchPresenters;
+  std::vector<std::unique_ptr<IBatchPresenter>> m_batchPresenters;
   std::unique_ptr<IBatchPresenterFactory> m_batchPresenterFactory;
 
 private:
diff --git a/qt/scientific_interfaces/test/ISISReflectometry/ReflMockObjects.h b/qt/scientific_interfaces/test/ISISReflectometry/ReflMockObjects.h
index 810cbf4b368..520b5f20d15 100644
--- a/qt/scientific_interfaces/test/ISISReflectometry/ReflMockObjects.h
+++ b/qt/scientific_interfaces/test/ISISReflectometry/ReflMockObjects.h
@@ -45,8 +45,8 @@ GNU_DIAG_OFF_SUGGEST_OVERRIDE
 class MockBatchPresenterFactory : public IBatchPresenterFactory {
 public:
   MOCK_METHOD1(makeProxy, IBatchPresenter *(IBatchView *));
-  std::shared_ptr<IBatchPresenter> make(IBatchView *view) {
-    return std::shared_ptr<IBatchPresenter>(makeProxy(view));
+  std::unique_ptr<IBatchPresenter> make(IBatchView *view) {
+    return std::unique_ptr<IBatchPresenter>(makeProxy(view));
   }
 };
 
-- 
GitLab