From 9455195e096ea5f9a82a358bf55b405029e13d2d Mon Sep 17 00:00:00 2001 From: "Christian.Linke" Date: Tue, 15 Dec 2015 05:42:04 -0800 Subject: deleting of instance explicit is needed --- .../include/CAmCommonAPIWrapper.h | 5 ++++ AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp | 28 ++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/AudioManagerUtilities/include/CAmCommonAPIWrapper.h b/AudioManagerUtilities/include/CAmCommonAPIWrapper.h index f2d701d..f9a6b01 100644 --- a/AudioManagerUtilities/include/CAmCommonAPIWrapper.h +++ b/AudioManagerUtilities/include/CAmCommonAPIWrapper.h @@ -112,6 +112,11 @@ public: */ static CAmCommonAPIWrapper* getInstance(); + /** + * \brief Deletes the instanciated object + */ + static void deleteInstance(); + /** * \brief Creates a singleton instance attached to the provided socket handler object. * diff --git a/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp b/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp index e756c19..8d2b82e 100644 --- a/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp +++ b/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp @@ -15,7 +15,7 @@ * For further information see http://www.genivi.org/. */ -#include +#include "audiomanagerconfig.h" #include #include #include @@ -80,17 +80,6 @@ CAmCommonAPIWrapper::~CAmCommonAPIWrapper() mContext.reset(); mpSocketHandler = NULL; mWatchToCheck = NULL; - try - { - if (pSingleCommonAPIInstance!=NULL) - delete pSingleCommonAPIInstance; - - pSingleCommonAPIInstance=NULL; - } - catch(...) - { - logError(__PRETTY_FUNCTION__,"error while deleting CAPIWrapper instance"); - } } CAmCommonAPIWrapper* CAmCommonAPIWrapper::instantiateOnce(CAmSocketHandler* socketHandler, const std::string & applicationName) @@ -107,6 +96,21 @@ CAmCommonAPIWrapper* CAmCommonAPIWrapper::instantiateOnce(CAmSocketHandler* sock return pSingleCommonAPIInstance; } +void CAmCommonAPIWrapper::deleteInstance() +{ + try + { + if (pSingleCommonAPIInstance!=NULL) + delete pSingleCommonAPIInstance; + + pSingleCommonAPIInstance=NULL; + } + catch(...) + { + logError(__PRETTY_FUNCTION__,"error while deleting CAPIWrapper instance"); + } +} + CAmCommonAPIWrapper* CAmCommonAPIWrapper::getInstance() { assert(NULL!=pSingleCommonAPIInstance); -- cgit v1.2.1