[ALOY-346] Unable to use createController('index')
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2012-11-15T22:33:41.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Runtime |
Labels | n/a |
Reporter | Benjamin Hatfield |
Assignee | Tony Lukasavage |
Created | 2012-10-25T19:40:57.000+0000 |
Updated | 2014-06-22T13:23:14.000+0000 |
Description
REPRODUCTION:
Run the following code on either the Android emulator or iOS simulator. Tried assigning an ID to the window and using it with getView. Same effect. Code works fine with other view-controllers besides index.
views/index.xml:
<Alloy>
<Window backgroundColor="red" title="Red Window"/>
</Alloy>
controllers/index.js:
var foo = require('foo');
foo.fooOpen();
lib/foo.js:
var Alloy = require('alloy');
exports.fooOpen = function(e) {
var win = Alloy.createController('index').getView();
win.open();
return;
}
RESULTS:
On the iPhone simulator, the Console View and simulator both report:
[ERROR] : Script Error = Maximum call stack size exceeded. at underscore.js (line 428).
On the Android emulator:
On the Console View, the following message is repeated:
[INFO] [2012-10-25 12:38:32,287] alloy/controllers/alloy/controllers/BaseController.js exists: false
[INFO] [2012-10-25 12:38:32,300] alloy/controllers/foo.js exists: false
On adb logcat | grep '^./Ti', the following message is repeated:
D/TiFastDev( 1154): (KrollRuntimeThread) [NN,50NNN] sent tokens successfully
On the emulator, the following message is displayed:
In ti:/path.js:71,23
Message: Uncaught RangeError: Maximum call stack size exceeded
Source: var path = arguments[i];
You are creating the index controller inside the index controller, which is creating an infinite loop, which in turn is why your call stack blows up. You can create a new "index" controller, you just need to do it in another controller.