Properly lock image.

This commit is contained in:
Relintai 2024-03-09 16:40:10 +01:00
parent c67d45375b
commit 3be690da76

View File

@ -2578,6 +2578,7 @@ Vector<Vector<Ref<Texture>>> LayeredTileSet::generate_terrains_icons(Size2i p_si
for (int terrain = 0; terrain < get_terrains_count(terrain_set); terrain++) { for (int terrain = 0; terrain < get_terrains_count(terrain_set); terrain++) {
Ref<Image> dst_image; Ref<Image> dst_image;
dst_image.instance(); dst_image.instance();
if (counts[terrain_set][terrain].count > 0) { if (counts[terrain_set][terrain].count > 0) {
// Get the best tile. // Get the best tile.
Ref<Texture> src_texture = counts[terrain_set][terrain].texture; Ref<Texture> src_texture = counts[terrain_set][terrain].texture;
@ -2592,8 +2593,12 @@ Vector<Vector<Ref<Texture>>> LayeredTileSet::generate_terrains_icons(Size2i p_si
dst_image->resize(p_size.x, p_size.y, Image::INTERPOLATE_NEAREST); dst_image->resize(p_size.x, p_size.y, Image::INTERPOLATE_NEAREST);
} else { } else {
dst_image->create(1, 1, false, Image::FORMAT_RGBA8); dst_image->create(1, 1, false, Image::FORMAT_RGBA8);
dst_image->lock();
dst_image->set_pixel(0, 0, get_terrain_color(terrain_set, terrain)); dst_image->set_pixel(0, 0, get_terrain_color(terrain_set, terrain));
dst_image->unlock();
} }
Ref<ImageTexture> icon; Ref<ImageTexture> icon;
icon.instance(); icon.instance();
icon->create_from_image(dst_image); icon->create_from_image(dst_image);