{ "id": "61157", "key": "TIMOB-525", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11224", "name": "Release 1.4.0", "archived": true, "released": true, "releaseDate": "2010-07-16" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:53:23.000+0000", "created": "2011-04-15T02:31:00.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "mobile", "settimeout" ], "versions": [], "issuelinks": [], "assignee": { "name": "rseagraves", "key": "rseagraves", "displayName": "Reggie Seagraves", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:53:23.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}{html}", "attachment": [], "flagged": false, "summary": "clearTimeout triggers the call instead of just clearing", "creator": { "name": "jaehess", "key": "jaehess", "displayName": "Jae Hess", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jaehess", "key": "jaehess", "displayName": "Jae Hess", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "123463", "author": { "name": "noah", "key": "noah", "displayName": "Noah", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Here is a reproducible test case.

\n

Make it your app.js and run it.

\n

How to reproduce:

\n
    \n
  1. Click \"move\"
  2. \n
  3. move a row. This sets a timeout to fire in 20 seconds.
  4. \n
  5. move another row within 20 seconds. The timeout will fire.
  6. \n
\n

I realize this could have been a simpler test, but I knew this\nwould reproduce the problem, since this is how I ran into it in the\nfirst place.

{html}", "updateAuthor": { "name": "noah", "key": "noah", "displayName": "Noah", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:31:00.000+0000", "updated": "2011-04-15T02:31:00.000+0000" }, { "id": "123464", "author": { "name": "nickwing", "key": "nickwing", "displayName": "Nick Wing", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Here's a stupidly simple broken test case:

\n
\nvar win = Titanium.UI.createWindow({ backgroundColor:'#fff' });\nwin.open();\nvar timer = setTimeout(function() { alert('You should never see me!'); }, 5000);\nclearTimeout(timer);\n
{html}", "updateAuthor": { "name": "nickwing", "key": "nickwing", "displayName": "Nick Wing", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:31:01.000+0000", "updated": "2011-04-15T02:31:01.000+0000" }, { "id": "123465", "author": { "name": "nickwing", "key": "nickwing", "displayName": "Nick Wing", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Here's a generalized workaround I came up with:

\n
\nfunction timeoutObject() { this.flag = true; }\nfunction mySetTimeout(callback, time) {\n  var myCallback = callback;\n  if (typeof callback == 'string') {
\n
\n\n\n
\n
\n
\nmyCallback = function() { eval(callback); };\n
\n
\n\n\n
\n }\n var timerobj = new timeoutObject();\n setTimeout(function () { \n\n
\n
\nif (timerobj.flag) { myCallback(); }\n
\n
\n\n\n
\n }, time);\n return timerobj;\n}\nfunction myClearTimeout(timer) {\n timer.flag = false;\n}\n
{html}", "updateAuthor": { "name": "nickwing", "key": "nickwing", "displayName": "Nick Wing", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:31:02.000+0000", "updated": "2011-04-15T02:31:02.000+0000" }, { "id": "123466", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [3f94bd90743f2c323216909fe50a016a16ea6dcf])\nCloses #525: Timers now stop before invocation if\ncancelled. \nhttp://github.com/appcelerator/titanium_mobile/commit/3f94bd90743f2...

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:31:02.000+0000", "updated": "2011-04-15T02:31:02.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }