From 2c2991d44ec275a31974e42eadfbcdd68c32a400 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 18 Aug 2015 12:50:52 -1000 Subject: [PATCH] switched to unique_ptr due to expected app main use --- include/boo/IApplication.hpp | 6 +++--- lib/x11/ApplicationUnix.cpp | 23 +++++++++++------------ test/main.cpp | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/boo/IApplication.hpp b/include/boo/IApplication.hpp index 2693a1e..fc88800 100644 --- a/include/boo/IApplication.hpp +++ b/include/boo/IApplication.hpp @@ -56,7 +56,7 @@ public: }; -std::shared_ptr +std::unique_ptr ApplicationBootstrap(IApplication::EPlatformType platform, IApplicationCallback& cb, const std::string& uniqueName, @@ -66,7 +66,7 @@ ApplicationBootstrap(IApplication::EPlatformType platform, bool singleInstance=true); extern IApplication* APP; -static inline std::shared_ptr +static inline std::unique_ptr ApplicationBootstrap(IApplication::EPlatformType platform, IApplicationCallback& cb, const std::string& uniqueName, @@ -75,7 +75,7 @@ ApplicationBootstrap(IApplication::EPlatformType platform, bool singleInstance=true) { if (APP) - return std::shared_ptr(APP); + return std::unique_ptr(); std::vector args; for (int i=1 ; i ApplicationBootstrap(IApplication::EPlatformType platform, +std::unique_ptr ApplicationBootstrap(IApplication::EPlatformType platform, IApplicationCallback& cb, const std::string& uniqueName, const std::string& friendlyName, @@ -56,17 +56,16 @@ std::shared_ptr ApplicationBootstrap(IApplication::EPlatformType p const std::vector& args, bool singleInstance) { - if (!APP) - { - if (platform == IApplication::PLAT_WAYLAND) - APP = new ApplicationWayland(cb, uniqueName, friendlyName, pname, args, singleInstance); - else if (platform == IApplication::PLAT_XCB || - platform == IApplication::PLAT_AUTO) - APP = new ApplicationXCB(cb, uniqueName, friendlyName, pname, args, singleInstance); - else - return std::shared_ptr(); - } - return std::shared_ptr(APP); + if (APP) + return std::unique_ptr(); + if (platform == IApplication::PLAT_WAYLAND) + APP = new ApplicationWayland(cb, uniqueName, friendlyName, pname, args, singleInstance); + else if (platform == IApplication::PLAT_XCB || + platform == IApplication::PLAT_AUTO) + APP = new ApplicationXCB(cb, uniqueName, friendlyName, pname, args, singleInstance); + else + return std::unique_ptr(); + return std::unique_ptr(APP); } } diff --git a/test/main.cpp b/test/main.cpp index 22d4989..2d78790 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -137,7 +137,7 @@ struct TestApplicationCallback : IApplicationCallback int main(int argc, const char** argv) { boo::TestApplicationCallback appCb; - std::shared_ptr app = + std::unique_ptr app = ApplicationBootstrap(boo::IApplication::PLAT_AUTO, appCb, "rwk", "RWK", argc, argv); app->run();