Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2027] Android: Weird behavior when setting custom sub properties on proxies

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:57:51.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0
ComponentsAndroid
Labelsandroid, custom, defect, kroll, properties, proxy
ReporterMarshall Culpepper
AssigneeMarshall Culpepper
Created2011-04-15T03:08:29.000+0000
Updated2011-04-17T01:57:51.000+0000

Description

An example from hal:

var viewInvRow = Ti.UI.createView(viewRowOptions);
Ti.API.info('----');
viewInvRow.customObj = "hello";
Ti.API.info('viewInvRow.customObj: '+viewInvRow.customObj); // output ok
viewInvRow.customObj = {};
viewInvRow.customObj.test = "hello";
Ti.API.info('viewInvRow.customObj.test: '+viewInvRow.customObj.test); // undefined
viewInvRow.customObj = { test : "hello" };
Ti.API.info('viewInvRow.customObj.test: '+viewInvRow.customObj.test); // output ok
Ti.API.info('----');

Comments

  1. Nathaniel McCallum 2011-04-15

    Something similar happens with this case (though, probably worse since its a crash):

       // The object that will cause a crash
       var X = function() {
               this.y = 1;
       };
       X.prototype.getY = function() {
               return this.y;
       };
       
       var x = new X();
       
       var row = Ti.UI.createTableViewRow();
       row.x = x;
       
       Ti.API.info(x.getY());     // 1.0
       Ti.API.info(row.x.getY()); // CRASH!
       

    Log:
    W/KrollConverter( 2859): (kroll$1) [351,491] Unhandled type conversion: value: {"y":1} type: org.appcelerator.kroll.KrollDict, invocation: [setProperty UI.TableViewRow.x null]
    I/TiAPI ( 2859): (kroll$1) [49,540] 1.0
    I/ActivityManager( 60): Displayed activity com.foo.foo/.FooActivity: 6077 ms (total 6077 ms)
    E/KrollContext( 2859): (kroll$1) [462,1002] ECMA Error evaluating source: TypeError: Cannot find default value for object. (app://app.js#14)
    E/KrollContext( 2859): org.mozilla.javascript.EcmaError: TypeError: Cannot find default value for object. (app://app.js#14)
    E/KrollContext( 2859): at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3761)
    E/KrollContext( 2859): at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3739)
    E/KrollContext( 2859): at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3767)
    E/KrollContext( 2859): at org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3779)
    E/KrollContext( 2859): at org.mozilla.javascript.ScriptableObject.getDefaultValue(ScriptableObject.java:839)
    E/KrollContext( 2859): at org.mozilla.javascript.ScriptableObject.getDefaultValue(ScriptableObject.java:758)
    E/KrollContext( 2859): at org.mozilla.javascript.ScriptRuntime.toString(ScriptRuntime.java:790)
    E/KrollContext( 2859): at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3848)
    E/KrollContext( 2859): at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2343)
    E/KrollContext( 2859): at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2310)
    E/KrollContext( 2859): at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1524)
    E/KrollContext( 2859): at script(app://app.js:14)
    E/KrollContext( 2859): at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
    E/KrollContext( 2859): at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
    E/KrollContext( 2859): at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
    E/KrollContext( 2859): at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3161)
    E/KrollContext( 2859): at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)
    E/KrollContext( 2859): at org.mozilla.javascript.Context.evaluateReader(Context.java:1142)
    E/KrollContext( 2859): at org.appcelerator.titanium.kroll.KrollContext.evaluateScript(KrollContext.java:193)
    E/KrollContext( 2859): at org.appcelerator.titanium.kroll.KrollContext.handleEvalFile(KrollContext.java:218)
    E/KrollContext( 2859): at org.appcelerator.titanium.kroll.KrollContext.handleMessage(KrollContext.java:115)
    E/KrollContext( 2859): at android.os.Handler.dispatchMessage(Handler.java:95)
    E/KrollContext( 2859): at android.os.Looper.loop(Looper.java:123)
    E/KrollContext( 2859): at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:73)

  2. Marshall Culpepper 2011-04-15

    (from [ee3b8859c349729bac353e413ef4eb051a51e86e]) implemented a new Scriptable wrapper extension of KrollDict so custom objects don't get lost in the conversion mix. added a test to make sure custom objects work correctly when put on proxies [#2027 state:fixed-in-qa] https://github.com/appcelerator/titanium_mobile/commit/ee3b8859c349729bac353e413ef4eb051a51e86e"> https://github.com/appcelerator/titanium_mobile/commit/ee3b8859c349...

  3. Matt Schmulen 2011-04-15

    pass Titanium SDK version: 1.5.0 (12/07/10 10:00 8f4eea3...), bugTest android Device 1.6/ sim 2.1

JSON Source