sdkbox / issues

The issue tracker for SDKBOX
MIT License
4 stars 0 forks source link

sdkbox::PluginSdkboxPlay::removeListener doesn't work #16

Closed alfogrillo closed 6 years ago

alfogrillo commented 7 years ago

How to reproduce: 1) Create two Scene A and B : public SdkboxPlayListener. 2) Overrides the two methods in B:

void B::::onExitTransitionDidStart()
{
    sdkbox::PluginSdkboxPlay::removeListener();
}
void B::onEnterTransitionDidFinish()
{
    sdkbox::PluginSdkboxPlay::setListener(this);
}

3) Add:

void B::onConnectionStatusChanged(int status) 
{
   log(__func__);
}

4) Pop back to scene A and change the connection status (use sdkbox::PluginSdkboxPlay::signin() and sdkbox::PluginSdkboxPlay::signout()). 5) Notice that B::onConnectionStatusChanged gets called. In other words sdkbox::PluginSdkboxPlay::removeListener() doesn't work properly!

This is dangerous because the methods of the listener typically access to properties of the Layer. But if the Scene was deallocated this generate an invalid memory access and then a crash.

Tested on Android device.

ghost commented 7 years ago

Thanks for your report, I'll fix it on 2.3.15

a workaround solution.

sdkbox::PluginSdkboxPlay::setListener(0);
ghost commented 7 years ago

fixed in 2.3.15, please use sdkbox update to update your plugins. Thanks,