Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23425] Windows: Ti.Blob.imageAs* methods crash the application when using a blob that does not represent an image

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-05-24T23:32:43.000+0000
Affected Version/sRelease 5.3.0
Fix Version/sRelease 5.4.0
ComponentsWindows
Labelsqe-5.3.0
ReporterEwan Harris
AssigneeGary Mathews
Created2016-05-23T18:07:12.000+0000
Updated2016-06-30T15:26:18.000+0000

Description

Description

When using the Ti.Blob.imageAs methods if they are given a blob that does not represent an image then the application will crash, based off the documentation and other platforms they should not crash but just return null [docs](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Blob-method-imageAsResized)
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'text.txt');
file.write('hi');
var win = Ti.UI.createWindow({
	backgroundColor: 'black'
});
var btn = Ti.UI.createButton({
	title: 'resized',
	top: 10
});
btn.addEventListener('click', function(){
	var file2 = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'text.txt');
	var text = file2.read();
	var resized = text.imageAsResized(25, 25);;
});
var btn2 = Ti.UI.createButton({
	title: 'cropped',
	top: 75
});
win.add(btn);
win.open();

Steps to reproduce

1. Using the code above build to a windows device or emulator

Actual result

Application will crash

Expected result

Application should not crash, methods should return null

Comments

  1. Gary Mathews 2016-05-24

    PR: https://github.com/appcelerator/titanium_mobile_windows/pull/717
  2. Ewan Harris 2016-06-30

    Verified using: Windows 10 Pro Ti SDK: 5.4.0.v20160629063537 Appc NPM: 4.2.7-2 Appc CLI: 5.4.0-23 Appc Studio: 4.7.0.201606220541 Lumia 930: 10.0 Lumia 520: 8.1 When using Ti.Blob.imageAs methods on a non-image, the app no longer crashes. Closing ticket

JSON Source