SeharAfzal / cocos2d-android-1

Automatically exported from code.google.com/p/cocos2d-android-1
0 stars 0 forks source link

CCTimer Swallows Exceptions #45

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
CCTimer has a generic try catch statement inside which is making debugging my 
game very hard. I'm not sure if this is new as of the last time I pulled. 
CCTimer has the following:

/** triggers the timer */
    public void update(float dt) {
        if (elapsed == -1) {
            elapsed = 0;
        } else {
            elapsed += dt;
        }
        if (elapsed >= interval) {
            if(callback != null) {
                callback.update(dt);
            } else {
                try {
                    invocation.invoke(target, new Object[]{elapsed});
                } catch (Exception e) {
                    e.printStackTrace();
                }               
            }
            elapsed = 0;
        }
    }

We should instead rethrow the exception.

Original issue reported on code.google.com by ghemp...@gmail.com on 22 Jan 2011 at 1:21

GoogleCodeExporter commented 8 years ago
Also if you change CCTimer, it propogates to another swallower CCSheduler:

                    } else {
                        try {
                            impMethod.invoke( elt.currentTimer, dt);
                        } catch (Exception e1) {
                            e1.printStackTrace();
                        }
                    }

I'm not sure if this code is just to make porting easier, but we should 
definitely change this behavior.

Original comment by ghemp...@gmail.com on 22 Jan 2011 at 1:35