Skip to content

Commit

Permalink
During load from json send error to reviver (#3586)
Browse files Browse the repository at this point in the history
* send error to reviver
* add error to imageFromObject
  • Loading branch information
asturur authored Dec 26, 2016
1 parent 700ee14 commit da25301
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/shapes/image.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,11 @@
* @param {Function} callback Callback to invoke when an image instance is created
*/
fabric.Image.fromObject = function(object, callback) {
fabric.util.loadImage(object.src, function(img) {
fabric.util.loadImage(object.src, function(img, error) {
if (error) {
callback && callback(null, error);
return;
}
fabric.Image.prototype._initFilters.call(object, object.filters, function(filters) {
object.filters = filters || [];
fabric.Image.prototype._initFilters.call(object, object.resizeFilters, function(resizeFilters) {
Expand Down
6 changes: 2 additions & 4 deletions src/util/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,8 @@
var klass = fabric.util.getKlass(o.type, namespace);
if (klass.async) {
klass.fromObject(o, function (obj, error) {
if (!error) {
enlivenedObjects[index] = obj;
reviver && reviver(o, enlivenedObjects[index]);
}
enlivenedObjects[index] = obj;
reviver && reviver(o, enlivenedObjects[index], error);
onLoaded();
});
}
Expand Down

0 comments on commit da25301

Please sign in to comment.