diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-04-02 19:51:14 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-04-02 19:51:14 +0100 |
commit | 4e6e296e5e38185c4d0854f909385cee70e4cfdc (patch) | |
tree | 416624aabdda92d00334149a4b1ca2adf78dda2d | |
parent | Tidy fixes for latest clang (diff) | |
download | libadhocutil-4e6e296e5e38185c4d0854f909385cee70e4cfdc.tar.bz2 libadhocutil-4e6e296e5e38185c4d0854f909385cee70e4cfdc.tar.xz libadhocutil-4e6e296e5e38185c4d0854f909385cee70e4cfdc.zip |
Don't use smart pointer for global static
It destructs itself way sooner than we want it to
-rw-r--r-- | libadhocutil/globalStatic.h | 2 | ||||
-rw-r--r-- | libadhocutil/globalStatic.impl.h | 7 | ||||
-rw-r--r-- | libadhocutil/unittests/testPlugins.cpp | 1 |
3 files changed, 5 insertions, 5 deletions
diff --git a/libadhocutil/globalStatic.h b/libadhocutil/globalStatic.h index 5808551..3639237 100644 --- a/libadhocutil/globalStatic.h +++ b/libadhocutil/globalStatic.h @@ -18,7 +18,7 @@ namespace AdHoc { static Object * get(); private: - typedef std::unique_ptr<Object> Ptr; + using Ptr = Object *; static void createObject() __attribute__((constructor(101))); static void deleteObject() __attribute__((destructor(101))); diff --git a/libadhocutil/globalStatic.impl.h b/libadhocutil/globalStatic.impl.h index fcd8096..13f2f72 100644 --- a/libadhocutil/globalStatic.impl.h +++ b/libadhocutil/globalStatic.impl.h @@ -7,19 +7,20 @@ namespace AdHoc { template<typename Object> Object * GlobalStatic<Object>::get() { - return instance().get(); + return instance(); } template<typename Object> void GlobalStatic<Object>::createObject() { - instance() = std::make_unique<Object>(); + instance() = new Object(); } template<typename Object> void GlobalStatic<Object>::deleteObject() { - instance().reset(); + delete instance(); + instance() = nullptr; } template<typename Object> diff --git a/libadhocutil/unittests/testPlugins.cpp b/libadhocutil/unittests/testPlugins.cpp index a8380fb..8d35822 100644 --- a/libadhocutil/unittests/testPlugins.cpp +++ b/libadhocutil/unittests/testPlugins.cpp @@ -79,7 +79,6 @@ BOOST_AUTO_TEST_CASE( createAndRemove ) auto c1 = PluginManager::getDefault()->get<BaseThing>("custom1"); BOOST_REQUIRE(c1); PluginManager::getDefault()->remove<BaseThing>("custom1"); - } BOOST_AUTO_TEST_CASE( nameAndTypeClash ) |