Merge pull request #50459 from MisoMosiSpy/image-lock-issue-3.x

Fixes 50428, added missing checks for image lock
This commit is contained in:
Rémi Verschelde 2021-07-14 22:49:10 +02:00 committed by GitHub
commit aecb1c32ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1237,7 +1237,7 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) { void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot crop in compressed or custom image formats."); ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot crop in compressed or custom image formats.");
ERR_FAIL_COND_MSG(write_lock.ptr(), "Cannot modify image when it is locked.");
ERR_FAIL_COND_MSG(p_x < 0, "Start x position cannot be smaller than 0."); ERR_FAIL_COND_MSG(p_x < 0, "Start x position cannot be smaller than 0.");
ERR_FAIL_COND_MSG(p_y < 0, "Start y position cannot be smaller than 0."); ERR_FAIL_COND_MSG(p_y < 0, "Start y position cannot be smaller than 0.");
ERR_FAIL_COND_MSG(p_width <= 0, "Width of image must be greater than 0."); ERR_FAIL_COND_MSG(p_width <= 0, "Width of image must be greater than 0.");
@ -1476,6 +1476,8 @@ void Image::expand_x2_hq2x() {
} }
void Image::shrink_x2() { void Image::shrink_x2() {
ERR_FAIL_COND(!_can_modify(format));
ERR_FAIL_COND_MSG(write_lock.ptr(), "Cannot modify image when it is locked.");
ERR_FAIL_COND(data.size() == 0); ERR_FAIL_COND(data.size() == 0);
if (mipmaps) { if (mipmaps) {
@ -1600,6 +1602,8 @@ void Image::normalize() {
Error Image::generate_mipmaps(bool p_renormalize) { Error Image::generate_mipmaps(bool p_renormalize) {
ERR_FAIL_COND_V_MSG(!_can_modify(format), ERR_UNAVAILABLE, "Cannot generate mipmaps in compressed or custom image formats."); ERR_FAIL_COND_V_MSG(!_can_modify(format), ERR_UNAVAILABLE, "Cannot generate mipmaps in compressed or custom image formats.");
ERR_FAIL_COND_V_MSG(write_lock.ptr(), ERR_UNAVAILABLE, "Cannot modify image when it is locked.");
ERR_FAIL_COND_V_MSG(format == FORMAT_RGBA4444 || format == FORMAT_RGBA5551, ERR_UNAVAILABLE, "Cannot generate mipmaps in custom image formats."); ERR_FAIL_COND_V_MSG(format == FORMAT_RGBA4444 || format == FORMAT_RGBA5551, ERR_UNAVAILABLE, "Cannot generate mipmaps in custom image formats.");
ERR_FAIL_COND_V_MSG(width == 0 || height == 0, ERR_UNCONFIGURED, "Cannot generate mipmaps with width or height equal to 0."); ERR_FAIL_COND_V_MSG(width == 0 || height == 0, ERR_UNCONFIGURED, "Cannot generate mipmaps with width or height equal to 0.");
@ -3148,6 +3152,9 @@ void Image::premultiply_alpha() {
} }
void Image::fix_alpha_edges() { void Image::fix_alpha_edges() {
ERR_FAIL_COND(!_can_modify(format));
ERR_FAIL_COND_MSG(write_lock.ptr(), "Cannot modify image when it is locked.");
if (data.size() == 0) { if (data.size() == 0) {
return; return;
} }