From 83be06bafb1abca2dfbb549291c88726f68d4f72 Mon Sep 17 00:00:00 2001 From: Rene Klacan Date: Mon, 10 Jun 2013 00:54:31 +0200 Subject: [PATCH] check if delegate is not null when dispatching keyboard event --- cocos2dx/keyboard_dispatcher/CCKeyboardDispatcher.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cocos2dx/keyboard_dispatcher/CCKeyboardDispatcher.cpp b/cocos2dx/keyboard_dispatcher/CCKeyboardDispatcher.cpp index 7f1ce3c61f..6603f47a77 100755 --- a/cocos2dx/keyboard_dispatcher/CCKeyboardDispatcher.cpp +++ b/cocos2dx/keyboard_dispatcher/CCKeyboardDispatcher.cpp @@ -54,14 +54,18 @@ void CCKeyboardDispatcher::setKeyReleaseDelegate(CCKeyboardDelegate delegate) bool CCKeyboardDispatcher::dispatchKeyboardEvent(int keyCode, bool pressed) { - if (pressed) + if (m_keyPressDelegate != NULL && pressed) { m_keyPressDelegate(keyCode); } - else + else if (m_keyReleaseDelegate != NULL) { m_keyReleaseDelegate(keyCode); } + else + { + return false; + } return true; }