diff options
author | Yingjie Wang <yingjiewang@codeaurora.org> | 2020-04-01 12:55:18 +0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2020-10-07 01:13:31 -0700 |
commit | 577ae9b36d34cdc585e8d0bce3bd98eca9e8c13c (patch) | |
tree | 9d958d279d490a4a11b334504e00d1ad1b876e20 | |
parent | eb68997c676b9a1f2a85ea514d91afa2397033af (diff) |
Delete LocationAPI instance after destroy() call
Change-Id: Ia48377b74b6c2d3aa52d6b9e18d3e43d06bbf93b
CRs-fixed: 2658368
-rw-r--r-- | location/LocationAPI.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/location/LocationAPI.cpp b/location/LocationAPI.cpp index 5c4be47..06c1e46 100644 --- a/location/LocationAPI.cpp +++ b/location/LocationAPI.cpp @@ -132,9 +132,11 @@ void LocationAPI::onRemoveClientCompleteCb (LocationAdapterTypeMask adapterType) } pthread_mutex_unlock(&gDataMutex); - if ((true == invokeCallback) && (nullptr != destroyCompleteCb)) { + if (invokeCallback) { LOC_LOGd("invoke client destroy cb"); - (destroyCompleteCb) (); + if (!destroyCompleteCb) { + (destroyCompleteCb) (); + } delete this; } @@ -286,7 +288,7 @@ LocationAPI::destroy(locationApiDestroyCompleteCallback destroyCompleteCb) gData.clientData.erase(it); - if ((NULL != destroyCompleteCb) && (false == needToWait)) { + if (!needToWait) { invokeDestroyCb = true; } } else { @@ -295,8 +297,10 @@ LocationAPI::destroy(locationApiDestroyCompleteCallback destroyCompleteCb) } pthread_mutex_unlock(&gDataMutex); - if (invokeDestroyCb == true) { - (destroyCompleteCb) (); + if (invokeDestroyCb) { + if (!destroyCompleteCb) { + (destroyCompleteCb) (); + } delete this; } } |