Event's subclass should not be allocated on stack.

This commit is contained in:
James Chen
2017-07-24 11:47:49 +08:00
parent ecbf26e5e4
commit b97be2db09
9 changed files with 21 additions and 9 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ bool Configuration::init()
Configuration::~Configuration()
{
CC_SAFE_DELETE(_loadedEvent);
CC_SAFE_RELEASE(_loadedEvent);
}
std::string Configuration::getInfo() const
+6 -6
View File
@@ -192,12 +192,12 @@ Director::~Director(void)
CC_SAFE_RELEASE(_actionManager);
CC_SAFE_DELETE(_defaultFBO);
delete _eventBeforeUpdate;
delete _eventAfterUpdate;
delete _eventAfterDraw;
delete _eventAfterVisit;
delete _eventProjectionChanged;
delete _eventResetDirector;
CC_SAFE_RELEASE(_eventBeforeUpdate);
CC_SAFE_RELEASE(_eventAfterUpdate);
CC_SAFE_RELEASE(_eventAfterDraw);
CC_SAFE_RELEASE(_eventAfterVisit);
CC_SAFE_RELEASE(_eventProjectionChanged);
CC_SAFE_RELEASE(_eventResetDirector);
delete _renderer;
+1
View File
@@ -48,6 +48,7 @@ public:
EventAcceleration(const Acceleration& acc);
private:
virtual ~EventAcceleration() {}
Acceleration _acc;
friend class EventListenerAcceleration;
};
+2
View File
@@ -66,6 +66,8 @@ public:
*/
inline const std::string& getEventName() const { return _eventName; };
protected:
virtual ~EventCustom() {}
void* _userData; ///< User data
std::string _eventName;
};
+2
View File
@@ -54,6 +54,8 @@ public:
EventFocus(ui::Widget* widgetLoseFocus, ui::Widget* widgetGetFocus);
private:
virtual ~EventFocus() {}
ui::Widget *_widgetGetFocus;
ui::Widget *_widgetLoseFocus;
+2
View File
@@ -228,6 +228,8 @@ public:
EventKeyboard(KeyCode keyCode, bool isPressed);
private:
virtual ~EventKeyboard() {}
KeyCode _keyCode;
bool _isPressed;
+2
View File
@@ -174,6 +174,8 @@ public:
private:
virtual ~EventMouse() {}
MouseEventType _mouseEventType;
int _mouseButton;
float _x;
+2
View File
@@ -88,6 +88,8 @@ public:
#endif
private:
virtual ~EventTouch() {}
EventCode _eventCode;
std::vector<Touch*> _touches;
+3 -2
View File
@@ -263,9 +263,10 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher;
NSAssert(false, @"unknown orientation");
}
cocos2d::EventAcceleration event(*_acceleration);
cocos2d::EventAcceleration* event = new (std::nothrow) cocos2d::EventAcceleration(*_acceleration);
auto dispatcher = cocos2d::Director::getInstance()->getEventDispatcher();
dispatcher->dispatchEvent(&event);
dispatcher->dispatchEvent(event);
event->release();
}
@end
#endif // !defined(CC_TARGET_OS_TVOS)