From 21d284df340c2c20d20e4b75120cff039a46ca54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 19 May 2020 18:02:05 +0200 Subject: [PATCH] Session now holds Config in unique_ptr instead of shared_ptr --- src/catch2/catch_session.cpp | 8 ++++---- src/catch2/catch_session.hpp | 2 +- src/catch2/internal/catch_context.cpp | 6 +++--- src/catch2/internal/catch_context.hpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp index f82c8ea0..351deb8d 100644 --- a/src/catch2/catch_session.cpp +++ b/src/catch2/catch_session.cpp @@ -137,7 +137,7 @@ namespace Catch { const auto& exceptions = getRegistryHub().getStartupExceptionRegistry().getExceptions(); if ( !exceptions.empty() ) { config(); - getCurrentMutableContext().setConfig(m_config); + getCurrentMutableContext().setConfig(m_config.get()); m_startupExceptions = true; Colour colourGuard( Colour::Red ); @@ -181,7 +181,7 @@ namespace Catch { auto result = m_cli.parse( clara::Args( argc, argv ) ); if( !result ) { config(); - getCurrentMutableContext().setConfig(m_config); + getCurrentMutableContext().setConfig(m_config.get()); Catch::cerr() << Colour( Colour::Red ) << "\nError(s) in input:\n" @@ -252,7 +252,7 @@ namespace Catch { } Config& Session::config() { if( !m_config ) - m_config = std::make_shared( m_configData ); + m_config = std::make_unique( m_configData ); return *m_config; } @@ -274,7 +274,7 @@ namespace Catch { } // Set up global config instance before we start calling into other functions - getCurrentMutableContext().setConfig(m_config); + getCurrentMutableContext().setConfig(m_config.get()); // Create reporter(s) so we can route listings through them auto reporter = makeReporter(m_config.get()); diff --git a/src/catch2/catch_session.hpp b/src/catch2/catch_session.hpp index e6269532..54fe37dd 100644 --- a/src/catch2/catch_session.hpp +++ b/src/catch2/catch_session.hpp @@ -53,7 +53,7 @@ namespace Catch { clara::Parser m_cli; ConfigData m_configData; - std::shared_ptr m_config; + std::unique_ptr m_config; bool m_startupExceptions = false; }; diff --git a/src/catch2/internal/catch_context.cpp b/src/catch2/internal/catch_context.cpp index 101db6aa..ed7b0150 100644 --- a/src/catch2/internal/catch_context.cpp +++ b/src/catch2/internal/catch_context.cpp @@ -22,7 +22,7 @@ namespace Catch { } IConfig const* getConfig() const override { - return m_config.get(); + return m_config; } ~Context() override; @@ -34,14 +34,14 @@ namespace Catch { void setRunner( IRunner* runner ) override { m_runner = runner; } - void setConfig( IConfigPtr const& config ) override { + void setConfig( IConfig const* config ) override { m_config = config; } friend IMutableContext& getCurrentMutableContext(); private: - IConfigPtr m_config; + IConfig const* m_config = nullptr; IRunner* m_runner = nullptr; IResultCapture* m_resultCapture = nullptr; }; diff --git a/src/catch2/internal/catch_context.hpp b/src/catch2/internal/catch_context.hpp index 4fb5461b..1f64d7f9 100644 --- a/src/catch2/internal/catch_context.hpp +++ b/src/catch2/internal/catch_context.hpp @@ -33,7 +33,7 @@ namespace Catch { virtual ~IMutableContext(); virtual void setResultCapture( IResultCapture* resultCapture ) = 0; virtual void setRunner( IRunner* runner ) = 0; - virtual void setConfig( IConfigPtr const& config ) = 0; + virtual void setConfig( IConfig const* config ) = 0; private: static IMutableContext *currentContext;