{ "id": "65546", "key": "AC-2975", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2011-05-31T02:25:22.000+0000", "created": "2011-05-18T12:57:38.000+0000", "labels": [ "iOS", "scope" ], "versions": [], "issuelinks": [], "assignee": { "name": "tguntharp", "key": "tguntharp", "displayName": "Tony Guntharp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:47:59.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "Code below shows how calling Ti.UI.createWindow from a global object method when the method is called from sub-context reference it produces no error, only returning undefined. Expected would be a throw error or a TiUIWindow object returned in line 10 of app.js. Wether it should or not, this code works on 1.6.3.\n\n{code:title=app.js|borderStyle=solid}\nTitanium.UI.setBackgroundColor('#000');\n\nvar app = {\n windows: [],\n Window: function(id) {\n if (!this.windows[id]) {\n this.windows[id] = Ti.UI.createWindow({url: id + '.js'});\n Ti.API.log('created window: ' + JSON.stringify(this.windows[id]));\n this.windows[id].app = this;\n }\n this.windows[id].open();\n return this.windows[id];\n }\n};\n\napp.Window('win').open();\n{code}\n{code:title=win.js|borderStyle=solid}\n({\n init: function() {\n var button = Ti.UI.createButton({ bottom: 0, title: \"open win2\", width: '100%', height: '10%' });\n button.addEventListener('click', function(e) {\n Ti.UI.currentWindow.app.Window('win2');\n });\n\n Ti.UI.currentWindow.add(button);\n }\n}).init();\n{code}\n\nLog when button is clicked:\n{noformat}\n[INFO] scopebug/1.0 (1.7.0.a41eefd...)\n[DEBUG] Analytics is enabled = YES\n[DEBUG] loading: /Users/jclark/Documents/Titanium Studio Workspace/scopebug/Resources/app.js, resource: Users/jclark/Documents/Titanium Studio Workspace/scopebug/Resources/app_js\n[INFO] created window: {\"orientationModes\":null,\"url\":\"win.js\"}\n[DEBUG] application booted in 32.694995 ms\n[DEBUG] loading: /Users/jclark/Documents/Titanium Studio Workspace/scopebug/Resources/win.js, resource: Users/jclark/Documents/Titanium Studio Workspace/scopebug/Resources/win_js\n[INFO] created window: undefined\n[WARN] Exception in event callback. {\nexpressionBeginOffset = 391;\nexpressionCaretOffset = 407;\nexpressionEndOffset = 418;\nline = 10;\nmessage = \"Result of expression 'this.windows[id]' [undefined] is not an object.\";\nname = TypeError;\nsourceId = 116344464;\nsourceURL = \"file://localhost/Users/jclark/Documents/Titanium%20Studio%20Workspace/scopebug/Resources/app.js\";\n}\n{noformat}\n", "attachment": [], "flagged": false, "summary": "Ti.UI.createWindow lost from scope in sub-context global reference", "creator": { "name": "h0tw1r3", "key": "h0tw1r3", "displayName": "Jeffrey Clark", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "h0tw1r3", "key": "h0tw1r3", "displayName": "Jeffrey Clark", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "osx 10.6.7, xcode 4.2, continuous build May 17 2011 23:08 ra41eefda", "comment": { "comments": [ { "id": "134449", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "This request is subjective - the log indicates that there is a problem with the code that needs to be resolved:\n\n{code}\n[WARN] Exception in event callback. {\nexpressionBeginOffset = 391;\nexpressionCaretOffset = 407;\nexpressionEndOffset = 418;\nline = 10;\nmessage = \"Result of expression 'this.windows[id]' [undefined] is not an object.\";\nname = TypeError;\nsourceId = 116344464;\n{code}\n\nIf you can demonstrate that the window is lost from scope in sub-context for *working code*, then we can progress this.", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-05-30T06:17:41.000+0000", "updated": "2011-05-30T06:17:41.000+0000" }, { "id": "134470", "author": { "name": "h0tw1r3", "key": "h0tw1r3", "displayName": "Jeffrey Clark", "active": true, "timeZone": "America/Los_Angeles" }, "body": "You can see the code work without error by running it on Android (I should have made that clear in the report). It also works with earlier SDK versions on any platform.\n\nEither way, the scope issue was addressed in [Commit f5912fe7538947f0654a |https://github.com/appcelerator/titanium_mobile/commit/f5912fe7538947f0654a971009533fbc6b044c58#commitcomment-407054].", "updateAuthor": { "name": "h0tw1r3", "key": "h0tw1r3", "displayName": "Jeffrey Clark", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-05-30T19:43:06.000+0000", "updated": "2011-05-30T19:44:23.000+0000" }, { "id": "134472", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Jeffrey, your code produced an error on Android when I tested it. ", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-05-31T02:24:20.000+0000", "updated": "2011-05-31T02:24:20.000+0000" }, { "id": "134473", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Resolved in ticket TIMOB-4074", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-05-31T02:25:22.000+0000", "updated": "2011-05-31T02:25:22.000+0000" }, { "id": "163076", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Closed after 30 days of inactivity.", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-08-16T16:45:37.000+0000", "updated": "2011-08-16T16:45:37.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }