Fix null pointer check and callback setup in IAP_SetListener function

This commit is contained in:
Nick Leeman 2024-04-26 23:06:15 +02:00
parent 406a594c8d
commit 6e27d8ad2e

View File

@ -213,8 +213,9 @@ static int IAP_SetListener(lua_State* L)
bool had_previous = iap->m_Listener != 0;
if (iap->m_Listener)
if (iap->m_Listener) {
dmScript::DestroyCallback(iap->m_Listener);
}
iap->m_Listener = dmScript::CreateCallback(L, 1);
@ -223,7 +224,10 @@ static int IAP_SetListener(lua_State* L)
dmAndroid::ThreadAttacher threadAttacher;
JNIEnv* env = threadAttacher.GetEnv();
env->CallVoidMethod(g_IAP.m_IAP, g_IAP.m_ProcessPendingConsumables, g_IAP.m_IAPJNI);
dmLogInfo("IAP: Processing pending transactions");
}
dmLogInfo("IAP listener set");
return 0;
}
@ -348,7 +352,7 @@ static void HandlePurchaseResult(const IAPCommand* cmd)
if (!dmScript::SetupCallback(cmd->m_Callback))
{
dmLogError("Failed to setup callback");
dmLogError("No callback set for purchase result!");
assert(top == lua_gettop(L));
return;
}