[TIMOB-23301] Windows: Ti.API.log doesn't handle single argument
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-05-03T17:48:31.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 5.3.0 |
| Components | Windows |
| Labels | qe-5.3.0 |
| Reporter | Nazmus Salahin |
| Assignee | Christopher Williams |
| Created | 2016-05-02T13:39:49.000+0000 |
| Updated | 2016-05-09T20:53:28.000+0000 |
Description
Hello,
I have found that
Ti.Locale.setLanguage works on Android but not on Windows Phone.
*Steps:*
1. Create a default classic project.
2. Replace app.js code with following.
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
win1.open();
var lan=Ti.Locale.getCurrentLanguage();
Ti.API.log("Initial Language: "+lan);
Ti.Locale.setLanguage("fr");
lan=Ti.Locale.getCurrentLanguage();
Ti.API.log("Language Changed To: "+lan);
3. Build and run the app.
4.On Android following console log is produced.
[INFO] : Initial Language: en
[INFO] : Language Changed To: fr
But on Windows Phone the app fails to run and following error log is produced.
[ERROR] : Application Error: {
[ERROR] : "line": 2,
[ERROR] : "column": 10,
[ERROR] : "message": "Error while require(/app) invalid vector<T> subscript",
[ERROR] : "native_stack": [
[ERROR] : "JSExportClass<class Titanium::GlobalObject>::CallNamedFunction"
[ERROR] : ]
[ERROR] : }
Thanks
*Environment*:
*Device info:* Nexus7 (android 6.0.1) , Microsoft Lumia 640 (Windows Phone 8.1)
*Node.js Version:* 0.12.7
*npm Version:* 2.11.3
*Titanium SDKs:* 5.2.2.GA and 5.2.1.GA
*Java Development Kit Version:* 1.8.0_73
*Titanium CLI Version:* 5.0.5
*Appcelerator CLI Version:* 5.2.2
*Appcelerator Studio:* 4.5.0
My best guess is that in the Ti.Locale constructor where we do:
That's failing becauseGlobalizationPreferences::Languagesis empty?https://github.com/appcelerator/titanium_mobile_windows/pull/656 https://github.com/appcelerator/titanium_mobile_windows/pull/657
The problem is Ti.API.log.
This works https://docs.appcelerator.com/platform/latest/#!/api/Titanium.API-method-log level is not working correctly on Windowsvar win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); win1.open(); var lan = Ti.Locale.currentLanguage; Ti.API.info("Initial Language: " + lan);Hmm, I'm not even sure this is valid JS here. The Ti.API.log method takes two arguments, but in this sample there's only one arg. That's the likely cause of the issue here. I would say we should better handle this single arg call, though. It looks like Android handles this case and assume INFO level logging when we only get a single argument, and that the argument is the message. See https://github.com/appcelerator/titanium_mobile/blob/415bd6c66dcc55b1a59a59574f3babd3c3a84ede/android/runtime/v8/src/native/modules/APIModule.cpp#L188
Verified as fixed Tested on: Nokia Lumia 928 (8.1) Windows Simulator (8.1) Microsoft Lumia 640 (10) Windows Simulator (10) Windows 10 Studio: 4.6.0.201605030516 Ti SDK: 5.3.0.v20160509074015 Appc NPM: 4.2.5-5 App CLI: 5.3.0-44 Node v4.4.3 *Closing Ticket.*