Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android callback empty dictionary #1

Open
KirillBarkousky opened this issue Mar 30, 2013 · 2 comments
Open

Android callback empty dictionary #1

KirillBarkousky opened this issue Mar 30, 2013 · 2 comments

Comments

@KirillBarkousky
Copy link

Hi, i found a bug. When creating CCDictionary from JSON object we use autorelease object. And when parameters pass to Native equriment we get empty dictionary. So i added retatin when create CCDIctionary and release in every to_be_call function.

CCObject* NDKHelper::GetCCObjectFromJson(json_t *obj)
{
if (obj == NULL)
return NULL;

if (json_is_object(obj))
{
    CCDictionary *dictionary = CCDictionary::create();
    dictionary->retain();

.....

Log displayed issue:
{"calling_method_name":"getCoins","calling_method_params":{"coins":"0","gems":"0"}}
Ndk proceed key coins
Ndk proceed key gems
Ndk get dictionary with 2 keys
getCoins call
params count 0 //so we have empty dictionary
NULL string
NULL string

@aajiwani
Copy link
Owner

Hey KirillBarkousky,

First of all thanks for the bug report. I think if i will retain the
dictionary in the method, i will have a non released or an orphan pointer
hanging around. What i can do is, i can release the pointer outside my
function where i actually make the call, but again there would be
consistency issues in here. I will think of solving this bug in some other
way from which i can release the memory too after the use. I will let you
know.

Thanks once again for helping me out with the solution i made.

Thanks.

Amir Ali Jiwani
CTO
Pi Labs - http://pilabs.com

@aajiwani
Copy link
Owner

aajiwani commented May 2, 2013

Hey Kirill,

I have tried to resolve the bug of having null as dictionary. Can you please check it and tell me if its now giving you the correct value or not ? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants