Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2642] Android : Kroll get method for properties does not work correctly

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:59:41.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0 M02
ComponentsAndroid
Labelsandroid, defect, kroll, release-1.6.0
ReporterOpie Cyrus
AssigneeOpie Cyrus
Created2011-04-15T03:25:38.000+0000
Updated2011-04-17T01:59:41.000+0000

Description

Kroll get method returns undefined due to the "get" name check in KrollBindingUtils.java : createAccessorMethod never actually being passed when a get method is invoked. The name that is checked for either "get" or "set" is actually the name of the property without either of the prefixed modifiers.

The "get" check always fails so the execution passes to the "set" block and so set calls work correctly. When a get call is made, a null value is returned because the set logic is executed but no argument is passed in for a new value like a real set call would contain.

Attachments

FileDateSize
app.js2011-04-15T03:25:38.000+0000668

Comments

  1. Jeff Haynie 2011-04-15

    (from [717ec1ad88b14e60a630c6aaa23bf2172627e208]) [#2642 state:fixed-in-qa] Modified Kroll property binding so get methods will return actual values

    createAccessorMethod now takes a boolean isSet argument to specifc if the accessor request is for the get or set method. Value returned is not the actual stored value rather than null.
    https://github.com/appcelerator/titanium_mobile/commit/717ec1ad88b14e60a630c6aaa23bf2172627e208"> https://github.com/appcelerator/titanium_mobile/commit/717ec1ad88b1...

  2. Opie Cyrus 2011-04-15

    Please verify the fix via the attached test app. Basically, if you are able to set the property via both methods made available in the test app then the fix is good. The issue was with the default kroll generated get methods. So before the win.getTitle()call would fail.

  3. Don Thorp 2011-04-15

    Verified on G1/1.6 and Nexus One/2.2.1 using build #e1cb22a

    Used this modified version of app.js. It wasn't using the property.

       var win = Titanium.UI.createWindow({  
           title:'Window 1',
           backgroundColor:'#fff',
           navBarHidden: false
       });
       
       var button1 = Ti.UI.createButton({
           title: 'Set by method',
           top: 50
       });
       button1.addEventListener('click', function(e) {
           win.setTitle("New title set by method");
       
           var alertDialog = Ti.UI.createAlertDialog({message: win.getTitle()});
           alertDialog.show();
       });
       win.add(button1);
       
       var button2 = Ti.UI.createButton({
           title: 'Set by property',
           top: 150
       });
       button2.addEventListener('click', function(e) {
           win.title = "New title set by property";
       
           var alertDialog = Ti.UI.createAlertDialog({message: win.title});
           alertDialog.show();
       });
       win.add(button2);
       
       win.open();
       

JSON Source