From d4a3e7dff206252a33b4856c50c1cdef1916d1fb Mon Sep 17 00:00:00 2001 From: EndrII Date: Wed, 16 Aug 2023 13:34:40 +0200 Subject: [PATCH] fix qaservice (autoInstance method) --- isettings.h | 15 +++++++++++++++ qaservice.h | 4 ++-- settings.cpp | 4 ++++ settings.h | 7 +++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/isettings.h b/isettings.h index 9757906..4dcd8ad 100644 --- a/isettings.h +++ b/isettings.h @@ -104,7 +104,22 @@ public: */ void setMode(const SettingsSaveMode &mode); + /** + * @brief instance This method returns pointer to current settings object. + * @return pointer to current settings object. + * @see Service::instance + */ static ISettings* instance(); + + /** + * @brief initService This method initialize the global settings object. + * @param obj This is prepared settings object. You should create a your object monyaly, and add to initialization + * @code{cpp} + * bool result = initService(std::make_unique()); + * @endcode + * @return true if initialization finished successful else false. + * @see Service::initService + */ static bool initService(std::unique_ptr obj); public slots: diff --git a/qaservice.h b/qaservice.h index 35c9c4f..d8197b5 100644 --- a/qaservice.h +++ b/qaservice.h @@ -78,12 +78,12 @@ public: * @see deinitService * @see autoInstance */ - static Base* initService() { + static inline std::unique_ptr& initService() { auto& val = instancePrivat(); if(!val) { val.reset(new Base()); } - return val._data; + return val; } /** diff --git a/settings.cpp b/settings.cpp index 73bf540..8b22676 100644 --- a/settings.cpp +++ b/settings.cpp @@ -65,4 +65,8 @@ void Settings::setBoolOptions(const QSet &newBoolOptions) _boolOptions = newBoolOptions; } +bool Settings::initService() { + return ISettings::initService(std::make_unique()); +} + } diff --git a/settings.h b/settings.h index adf8b04..f4d0531 100644 --- a/settings.h +++ b/settings.h @@ -61,6 +61,13 @@ public: */ void setBoolOptions(const QSet &newBoolOptions); + /** + * @brief initService This method initialize default object of the QuasarAppUtils::Settings type. + * @return true if initialization finished successfull else false. + * @see ISettings::initService + */ + static bool initService(); + protected: void syncImplementation() override;