mirror of https://github.com/axmolengine/axmol.git
add m_pAccelDelegate != NULL to avoid crash
This commit is contained in:
parent
eb9cb31ca4
commit
f162a5fcaa
|
@ -55,7 +55,7 @@ CCAccelerometer* CCAccelerometer::sharedAccelerometer()
|
|||
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
||||
{
|
||||
m_pAccelDelegate = pDelegate;
|
||||
if (pDelegate)
|
||||
if (pDelegate != NULL)
|
||||
{
|
||||
setEnable(true);
|
||||
}
|
||||
|
@ -82,7 +82,10 @@ void CCAccelerometer::OnDataReceived(SensorType sensorType, SensorData& sensorDa
|
|||
AccValue.z = -z;
|
||||
AccValue.timestamp = timeStamp;
|
||||
|
||||
m_pAccelDelegate->didAccelerate(&AccValue);
|
||||
if (m_pAccelDelegate != NULL)
|
||||
{
|
||||
m_pAccelDelegate->didAccelerate(&AccValue);
|
||||
}
|
||||
AppLog("##TimeStamp:[%d], Accel.x,y,z:[%f,%f,%f]", timeStamp, x, y, z);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue