cocos2d-x / cocos2dx-win8

102 stars 66 forks source link

CCNotificationCenter is unable to post notifications for cocos2x-2.1.0-wp8-alpha-2.0 #26

Open saudahmed opened 11 years ago

saudahmed commented 11 years ago

When you postnotification by using the method below

void CCNotificationCenter::postNotification(const char name, CCObject *object) { CCObject obj = NULL; CCARRAY_FOREACH(m_observers, obj) { CCNotificationObserver* observer = (CCNotificationObserver*) obj; if (!observer) continue;

    CCLOG("observerName: %s", observer->getName());

    if (!strcmp(name,observer->getName()))
        observer->performSelector(object);
}

}

observer->getName() always gives an empty string. When I went through the constructor of CCNotificationObserver in m_name it places a garbage value and I believe this bug was reported and one forgot to fix it

CCNotificationObserver::CCNotificationObserver(CCObject target, SEL_CallFuncO selector, const char name, CCObject *obj) { m_target = target; m_selector = selector; m_object = obj;

m_name = new char[strlen(name)+1];
memset(m_name,0,strlen(name)+1);

string orig (name);

//bug fix me orig.copy(m_name,strlen(name),0); }

dumganhar commented 11 years ago

@QiMa I also want to know why they comment that line.

QiMa commented 11 years ago

I see. I will fix it these days.