mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
Event's subclass should not be allocated on stack.
This commit is contained in:
@@ -90,7 +90,7 @@ bool Configuration::init()
|
||||
|
||||
Configuration::~Configuration()
|
||||
{
|
||||
CC_SAFE_DELETE(_loadedEvent);
|
||||
CC_SAFE_RELEASE(_loadedEvent);
|
||||
}
|
||||
|
||||
std::string Configuration::getInfo() const
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
EventAcceleration(const Acceleration& acc);
|
||||
|
||||
private:
|
||||
virtual ~EventAcceleration() {}
|
||||
Acceleration _acc;
|
||||
friend class EventListenerAcceleration;
|
||||
};
|
||||
|
||||
@@ -66,6 +66,8 @@ public:
|
||||
*/
|
||||
inline const std::string& getEventName() const { return _eventName; };
|
||||
protected:
|
||||
virtual ~EventCustom() {}
|
||||
|
||||
void* _userData; ///< User data
|
||||
std::string _eventName;
|
||||
};
|
||||
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
EventFocus(ui::Widget* widgetLoseFocus, ui::Widget* widgetGetFocus);
|
||||
|
||||
private:
|
||||
virtual ~EventFocus() {}
|
||||
|
||||
ui::Widget *_widgetGetFocus;
|
||||
ui::Widget *_widgetLoseFocus;
|
||||
|
||||
|
||||
@@ -228,6 +228,8 @@ public:
|
||||
EventKeyboard(KeyCode keyCode, bool isPressed);
|
||||
|
||||
private:
|
||||
virtual ~EventKeyboard() {}
|
||||
|
||||
KeyCode _keyCode;
|
||||
bool _isPressed;
|
||||
|
||||
|
||||
@@ -174,6 +174,8 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
virtual ~EventMouse() {}
|
||||
|
||||
MouseEventType _mouseEventType;
|
||||
int _mouseButton;
|
||||
float _x;
|
||||
|
||||
@@ -88,6 +88,8 @@ public:
|
||||
#endif
|
||||
|
||||
private:
|
||||
virtual ~EventTouch() {}
|
||||
|
||||
EventCode _eventCode;
|
||||
std::vector<Touch*> _touches;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user