From c29c9edc52f869196072eaad432acc0d2814c000 Mon Sep 17 00:00:00 2001 From: EndrII Date: Thu, 6 Apr 2023 14:48:23 +0200 Subject: [PATCH] fix work service class on the android and windows apps for the shared applications --- qaservice.h | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/qaservice.h b/qaservice.h index b5b1ac0..ad36d48 100644 --- a/qaservice.h +++ b/qaservice.h @@ -78,12 +78,10 @@ public: */ template static Base* initService(Args&&... args) { - Service* instanceObj = privateInstance(); - if(!instanceObj->_data) { - instanceObj->_data = new BaseClass(std::forward(args)...); + if(!_data) { + _data = new BaseClass(std::forward(args)...); } - - return instanceObj->_data; + return _data; } /** @@ -95,7 +93,7 @@ public: * @see autoInstance */ static Base* instance() { - return privateInstance()->_data; + return _data; } /** @@ -105,11 +103,11 @@ public: */ static Base* autoInstance() { - if (!privateInstance()->_data) { + if (!_data) { initService(); } - return privateInstance()->_data; + return _data; } /** @@ -120,23 +118,20 @@ public: * @see autoInstance */ static void deinitService() { - Service* instanceObj = privateInstance(); - if(instanceObj->_data) { - delete instanceObj->_data; - instanceObj->_data = nullptr; + if(_data) { + delete _data; + _data = nullptr; } } private: - static Service* privateInstance() { - static Service* privateObject = new Service; - return privateObject; - }; + static Base* _data; - Base* _data = nullptr; }; +template +Base* Service::_data = nullptr; } #endif // QASERVICE_H