Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17994] Different button-properties set to NULL give: [WARN] could not find image: <null>

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsalloy, applyProperties, backgroundImage
ReporterFokke Zandbergen
AssigneeUnknown
Created2014-11-08T13:13:56.000+0000
Updated2020-01-21T09:49:20.000+0000

Description

The problem

While working on an Alloy project that used autoStyle on some views, I sow these 4 lines scrolling by all the time:
[WARN]  could not find image: <null>
[WARN]  could not find image: <null>
[WARN]  could not find image: <null>
[WARN]  could not find image: <null>

The source

I tracked it down to a call to $.removeClass($.proxy, \['class'\]). When Alloy removes a class it will use a [RESET object](https://github.com/appcelerator/alloy/blob/master/Alloy/lib/alloy.js#L38) as defaults for the remaining styles. I then made a test case that reproduces:
var w = Ti.UI.createWindow({
  backgroundColor: 'green'
});

var v = Ti.UI.createButton({        // replacing with Ti.UI.View reduces from 4 to 0 warning (!)
  width: 100,
  height: 100,
  backgroundColor: 'red'
});
w.add(v);

w.open();

v.applyProperties({
  "backgroundColor": 'red',         // removing reduces from 4 to 2 warnings
  "shadowColor": null,              // removing reduces from 4 to 2 warnings
  "shadowOffset": null,             // removing reduces from 4 to 2 warnings
  "backgroundImage": null,          // removing reduces from 4 to 1 warning (!)
  "backgroundRepeat": null,         // removing reduces from 4 to 2 warnings
  "backgroundSelectedColor": null,  // removing reduces from 4 to 2 warnings
  "backgroundSelectedImage": null,  // removing reduces from 4 to 1 warning (!)
  "visible": true,                  // removing reduces from 4 to 2 warnings
  "backgroundGradient": {},         // removing reduces from 4 to 2 warnings
  "borderRadius": 0,                // removing reduces from 4 to 2 warnings
  "backgroundLeftCap": 0,           // removing reduces from 4 to 2 warnings
  "backgroundTopCap": 0             // removing reduces from 4 to 2 warnings
});
The actually error must originate from: https://github.com/appcelerator/titanium_mobile/blob/58198c641d77e17d156431666e80bae732b5c130/iphone/Classes/TiUIView.m#L315 But what is weird is that on line 311 of the above source, it checks for the image to be nil which I assume the null values of the above test case should have been converted to. It's also striking that these warnings don't show for a View, but only for a Button. So the issue must be somewhere between lines 233 and 255 of [TiUIButton.m](https://github.com/appcelerator/titanium_mobile/blob/58198c641d77e17d156431666e80bae732b5c130/iphone/Classes/TiUIButton.m#L233-L255)

Comments

  1. Hans Knöchel 2015-02-03

    Having the same issue using $.resetClass(view, 'class1 class2');
  2. Joe 2019-07-11

    Still having this issue on 7.5.1GA when using $.resetClass(view, 'class1 class2');

JSON Source