[TIMOB-9322] Android: Adding Label properties after creation causes the application to crash
| GitHub Issue | n/a | 
|---|---|
| Type | Bug | 
| Priority | High | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2012-06-05T15:52:21.000+0000 | 
| Affected Version/s | Release 2.0.1 | 
| Fix Version/s | Release 2.1.0, Sprint 2012-12 API | 
| Components | Android | 
| Labels | Community, api, module_label, qe-testadded, regression | 
| Reporter | Pete Berry | 
| Assignee | Josh Roesslein | 
| Created | 2012-05-25T13:48:22.000+0000 | 
| Updated | 2012-07-13T16:27:27.000+0000 | 
Description
	This happens when numerous labels are created, one right after another.
The following example fails while creates 35 rows each with 25 columns. Notice that several properties for the label are set after the label is created:
var win1 = Ti.UI.currentWindow;
var BaleReportWindow = Ti.UI.currentWindow;
var HScrollView=Ti.UI.createScrollView({backgroundColor:'black',
                                        showVerticalScrollIndicator:false,
                                        showHorizontalScrollIndicator:true,
                                        scrollType:'horizontal'});
var VScrollView=Ti.UI.createScrollView({backgroundColor:'black',
                                        showVerticalScrollIndicator:true,
                                        showHorizontalScrollIndicator:false,
                                        scrollType:'vertical'});
Ti.UI.currentWindow.add(HScrollView);
HScrollView.add(VScrollView);
var RowCount=35;
var ColCount=25;
var RowHeight=21;
var ColWidth=50;
var TheLabel;
var TheRow;
var TheCol;
for (var Y=1; Y<=RowCount; Y++)
{
  TheRow=Ti.UI.createView({top:((Y-1)*RowHeight), 
                           height:RowHeight+1,
                           backgroundColor:'gray'});
  for (var X=1; X<=ColCount; X++)
  {
    TheLabel=Ti.UI.createLabel({text:Y + '.' + X,
/*  
                                color:'black',
                                left:1+((X-1)*(ColWidth+1)),
                                width:ColWidth,
                                height:RowHeight,
                                top:1,
 */                                
                                backgroundColor:'white'});
/* */                                 
    TheLabel.color='black';
    TheLabel.left=1+((X-1)*(ColWidth+1));
    TheLabel.width=ColWidth;
    TheLabel.height=RowHeight;
    TheLabel.top=1;
/* */                                    
    TheRow.add(TheLabel);
  }
  VScrollView.add(TheRow);
}
var win1 = Ti.UI.currentWindow;
var BaleReportWindow = Ti.UI.currentWindow;
var HScrollView=Ti.UI.createScrollView({backgroundColor:'black',
                                        showVerticalScrollIndicator:false,
                                        showHorizontalScrollIndicator:true,
                                        scrollType:'horizontal'});
var VScrollView=Ti.UI.createScrollView({backgroundColor:'black',
                                        showVerticalScrollIndicator:true,
                                        showHorizontalScrollIndicator:false,
                                        scrollType:'vertical'});
Ti.UI.currentWindow.add(HScrollView);
HScrollView.add(VScrollView);
var RowCount=35;
var ColCount=25;
var RowHeight=21;
var ColWidth=50;
var TheLabel;
var TheRow;
var TheCol;
for (var Y=1; Y<=RowCount; Y++)
{
  TheRow=Ti.UI.createView({top:((Y-1)*RowHeight), 
                           height:RowHeight+1,
                           backgroundColor:'gray'});
  for (var X=1; X<=ColCount; X++)
  {
    TheLabel=Ti.UI.createLabel({text:Y + '.' + X,
/* */
                                color:'black',
                                left:1+((X-1)*(ColWidth+1)),
                                width:ColWidth,
                                height:RowHeight,
                                top:1,
/* */                                
                                backgroundColor:'white'});
/*                                 
    TheLabel.color='black';
    TheLabel.left=1+((X-1)*(ColWidth+1));
    TheLabel.width=ColWidth;
    TheLabel.height=RowHeight;
    TheLabel.top=1;
 */                                    
    TheRow.add(TheLabel);
  }
  VScrollView.add(TheRow);
}
Sent [PR #2321](http://github.com/appcelerator/titanium_mobile/pull/2321) to resolve this issue. This also appears to fix the test case in TIMOB-8289.
Adding label properties after creation of label work fine and does not crash the application Verified on: Titanium Studio: 2.1.0.201206041625 Titanium SDK: 2.1.0.v20120605190238 Android SDK: Google APIs Android 2.3.3 Android Runtime: v8, Rhino
Please reopen this bug. Running the first bit of example code above still cause the application to fail with SDK version 2.1.0.GA. Thank you, Pete
Pete, could you provide us with a log of the crash?
Confirmed fixed in 2.1.0.GA