Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/image/loading_displaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ p5.prototype.loadImage = function(path, successCallback, failureCallback) {
e => {
if (typeof failureCallback === 'function') {
failureCallback(e);
self._decrementPreload();
} else {
console.error(e);
}
self._decrementPreload();
}
);
} else {
Expand All @@ -170,10 +170,10 @@ p5.prototype.loadImage = function(path, successCallback, failureCallback) {
p5._friendlyFileLoadError(0, img.src);
if (typeof failureCallback === 'function') {
failureCallback(e);
self._decrementPreload();
} else {
console.error(e);
}
self._decrementPreload();
};

// Set crossOrigin in case image is served with CORS headers.
Expand All @@ -193,10 +193,10 @@ p5.prototype.loadImage = function(path, successCallback, failureCallback) {
p5._friendlyFileLoadError(0, path);
if (typeof failureCallback === 'function') {
failureCallback(e);
self._decrementPreload();
} else {
console.error(e);
}
self._decrementPreload();
});
return pImg;
};
Expand Down
13 changes: 9 additions & 4 deletions src/io/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,9 @@ p5.prototype.loadJSON = function(...args) {
if (errorCallback) {
errorCallback(err);
} else {
throw err;
console.error(err);
}
self._decrementPreload();
}
);

Expand Down Expand Up @@ -494,8 +495,9 @@ p5.prototype.loadStrings = function(...args) {
if (errorCallback) {
errorCallback(err);
} else {
throw err;
console.error(err);
}
self._decrementPreload();
}
);

Expand Down Expand Up @@ -757,6 +759,7 @@ p5.prototype.loadTable = function(path) {
} else {
console.error(err);
}
self._decrementPreload();
}
);

Expand Down Expand Up @@ -975,8 +978,9 @@ p5.prototype.loadXML = function(...args) {
if (errorCallback) {
errorCallback(err);
} else {
throw err;
console.error(err);
}
self._decrementPreload();
}
);

Expand Down Expand Up @@ -1033,8 +1037,9 @@ p5.prototype.loadBytes = function(file, callback, errorCallback) {
if (errorCallback) {
errorCallback(err);
} else {
throw err;
console.error(err);
}
self._decrementPreload();
}
);
return ret;
Expand Down
6 changes: 4 additions & 2 deletions src/typography/loading_displaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ p5.prototype.loadFont = function(path, onSuccess, onError) {
if (err) {
p5._friendlyFileLoadError(4, path);
if (typeof onError !== 'undefined') {
return onError(err);
onError(err);
} else {
console.error(err, path);
}
console.error(err, path);
self._decrementPreload();
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/webgl/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ p5.prototype.loadModel = function(path,options) {
'Sorry, the file type is invalid. Only OBJ and STL files are supported.'
);
}
self._decrementPreload();
}
return model;
};
Expand Down