mirror of
https://github.com/QuasarApp/QuasarAppLib.git
synced 2025-04-26 17:54:40 +00:00
fix work service class on the android and windows apps for the shared applications
This commit is contained in:
parent
7737b28258
commit
c29c9edc52
29
qaservice.h
29
qaservice.h
@ -78,12 +78,10 @@ public:
|
||||
*/
|
||||
template<class BaseClass = Base, class... Args>
|
||||
static Base* initService(Args&&... args) {
|
||||
Service<Base>* instanceObj = privateInstance();
|
||||
if(!instanceObj->_data) {
|
||||
instanceObj->_data = new BaseClass(std::forward<Args>(args)...);
|
||||
if(!_data) {
|
||||
_data = new BaseClass(std::forward<Args>(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<Base>* instanceObj = privateInstance();
|
||||
if(instanceObj->_data) {
|
||||
delete instanceObj->_data;
|
||||
instanceObj->_data = nullptr;
|
||||
if(_data) {
|
||||
delete _data;
|
||||
_data = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static Service<Base>* privateInstance() {
|
||||
static Service<Base>* privateObject = new Service<Base>;
|
||||
return privateObject;
|
||||
};
|
||||
static Base* _data;
|
||||
|
||||
Base* _data = nullptr;
|
||||
|
||||
};
|
||||
|
||||
template<class Base>
|
||||
Base* Service<Base>::_data = nullptr;
|
||||
|
||||
}
|
||||
#endif // QASERVICE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user