summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Lorenz <jlorenz@de.adit-jv.com>2017-04-11 22:13:32 +0200
committerJens Lorenz <jlorenz@de.adit-jv.com>2017-04-11 22:20:10 +0200
commitcfe230db3654094c4c098eea2736c71dd97396d0 (patch)
tree304e30980de90f791a39f009e67c20dfd82c9b0b
parent3bd66bf4c57c03c2004a8f60234cd60f791c81b9 (diff)
downloadaudiomanager-cfe230db3654094c4c098eea2736c71dd97396d0.tar.gz
AMUtil: Fix nullptr exception in DLT singleton
Application might use libraries which are using CAmDltWrapper class. The singleton implementation requires an instanctiateOnce() initialization but if the application is not aware of this AudioManager utility a nullptr exception occurs on standard instance() calls. instance() checks now if the singleton exists and initializes the singleton and registers a fallback application towards DLT on demand. Signed-off-by: Jens Lorenz <jlorenz@de.adit-jv.com>
-rw-r--r--AudioManagerUtilities/src/CAmDltWrapper.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/AudioManagerUtilities/src/CAmDltWrapper.cpp b/AudioManagerUtilities/src/CAmDltWrapper.cpp
index dc594af..37a5ff0 100644
--- a/AudioManagerUtilities/src/CAmDltWrapper.cpp
+++ b/AudioManagerUtilities/src/CAmDltWrapper.cpp
@@ -157,6 +157,15 @@ CAmDltWrapper* CAmDltWrapper::instanctiateOnce(const char *appid, const char * d
CAmDltWrapper* CAmDltWrapper::instance()
{
+ if (!mpDLTWrapper)
+ {
+ // an application seems not to use our CAmDltWrapper class therefore create default
+ std::ostringstream description;
+ description << "PID=" << getpid() << " _=" << getenv("_");
+ mpDLTWrapper = new CAmDltWrapper("AMDL", description.str().c_str());
+ std::cerr << "Application doesn't call CAmDltWrapper::instanciateOnce!!!" << std::endl;
+ std::cerr << "-> CAmDltWrapper::instance registers DLT application [ AMDL | " << description.str() << " ]" << std::endl;
+ }
return mpDLTWrapper;
}