fixed a null pointer exception bug

This commit fix the bug if a event is dispatched and no listener registered on it.