From 4f89e048fd1fa02d0f18cc402b24af2cd5adca8b Mon Sep 17 00:00:00 2001 From: Bhakta Date: Mon, 11 Jan 2016 18:04:37 +0530 Subject: [PATCH] Fixed for app crash if push configured (cherry picked from commit aff07946a432d4d1e05599110afc4ba485105d55) --- lib/commonAPI/coreapi/ext/shared/PushImpl.cpp | 9 ++++++++- platform/android/Rhodes/jni/src/rhodesapp.cpp | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/commonAPI/coreapi/ext/shared/PushImpl.cpp b/lib/commonAPI/coreapi/ext/shared/PushImpl.cpp index 3f68e88513f..f1e5db0ef21 100644 --- a/lib/commonAPI/coreapi/ext/shared/PushImpl.cpp +++ b/lib/commonAPI/coreapi/ext/shared/PushImpl.cpp @@ -37,7 +37,14 @@ namespace push { //---------------------------------------------------------------------------------------------------------------------- CPushManager* CPushManager::getInstance() { - return reinterpret_cast(CPushFactoryBase::getInstance()->getModuleSingleton()); + CPushFactoryBase* pInstance = CPushFactoryBase::getInstance(); + if (pInstance){ + LOG(TRACE) + "Returning CPushManager Instance"; + return reinterpret_cast(pInstance->getModuleSingleton()); + }else{ + LOG(TRACE) + "CPushFactoryBase::getInstance is empty. Returning 0"; + return 0; + } } //---------------------------------------------------------------------------------------------------------------------- diff --git a/platform/android/Rhodes/jni/src/rhodesapp.cpp b/platform/android/Rhodes/jni/src/rhodesapp.cpp index 9cfdbaccaf6..963b38af8a9 100644 --- a/platform/android/Rhodes/jni/src/rhodesapp.cpp +++ b/platform/android/Rhodes/jni/src/rhodesapp.cpp @@ -332,7 +332,12 @@ RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_RhodesService_setPushRegistrat std::string strType = jType ? rho_cast(env, jType) : ""; std::string deviceId = rho_cast(env, jId); - rho::push::CPushManager::getInstance()->setDeviceId(strType, deviceId); + rho::push::CPushManager* pInstance = rho::push::CPushManager::getInstance(); + if (pInstance){ + pInstance->setDeviceId(strType, deviceId); + }else{ + RAWTRACE("rho::push::CPushManager::getInstance is empty"); + } } RHO_GLOBAL jboolean JNICALL Java_com_rhomobile_rhodes_RhodesService_callPushCallback