* Added check if remove() method exists in a prototype's constructor

* Fixed bug that caused exception when calling Layout.reset() due to undefined main skin of a third-party prototype (e.g. Feed)
This commit is contained in:
Tobi Schäfer 2008-04-27 10:54:07 +00:00
parent 271e48eaa9
commit dff39778a6
2 changed files with 11 additions and 3 deletions

View file

@ -115,7 +115,9 @@ HopObject.remove = function(collection) {
var item;
while (collection.size() > 0) {
item = collection.get(0);
item.constructor.remove.call(item, item);
if (item.constructor.remove) {
item.constructor.remove.call(item, item);
}
}
return;
}

View file

@ -229,6 +229,9 @@ Skin.prototype.setSource = function(source) {
res.writeln(source.trim());
}
var skin = this.getMainSkin();
if (!skin) {
return;
}
var subskins = skin.getSubskinNames();
for (var i in subskins) {
if (subskins[i] !== this.name) {
@ -262,8 +265,11 @@ Skin.prototype.getStaticFile = function(fpath, skin) {
}
Skin.prototype.getMainSkin = function() {
var source = app.getSkinfilesInPath(res.skinpath)[this.prototype][this.prototype];
return createSkin(source);
var skinSet = app.getSkinfilesInPath(res.skinpath)[this.prototype];
if (skinSet && skinSet[this.prototype]) {
return createSkin(skinSet[this.prototype]);
}
return null;
}
Skin.prototype.custom_macro = function() {