瀏覽代碼

Merge pull request #87920 from kleonc/image-doc-unlocking-methods-3x

[3.x] Document some `Image` methods can unlock it (making `set_pixel` fail)
Rémi Verschelde 1 年之前
父節點
當前提交
6f8d35138b
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      doc/classes/Image.xml

+ 14 - 0
doc/classes/Image.xml

@@ -385,6 +385,13 @@
 				img.unlock()
 				img.set_pixel(x, y, color) # Does not have an effect
 				[/codeblock]
+				[b]Note:[/b] Some image methods can leave the image unlocked, making subsequent [method set_pixel] calls fail unless the image is locked again. Methods potentially unlocking the image: [method blend_rect], [method blend_rect_mask], [method blit_rect_mask], [method convert], [method fill], [method fill_rect], [method get_used_rect], and [method rgbe_to_srgb].
+				[codeblock]
+				img.lock()
+				img.set_pixel(x, y, color) # Works
+				img.fill(color) # Unlocks the image
+				img.set_pixel(x, y, color) # Does not have an effect
+				[/codeblock]
 			</description>
 		</method>
 		<method name="set_pixelv">
@@ -401,6 +408,13 @@
 				img.unlock()
 				img.set_pixelv(Vector2(x, y), color) # Does not have an effect
 				[/codeblock]
+				[b]Note:[/b] Some image methods can leave the image unlocked, making subsequent [method set_pixelv] calls fail unless the image is locked again. Methods potentially unlocking the image: [method blend_rect], [method blend_rect_mask], [method blit_rect_mask], [method convert], [method fill], [method fill_rect], [method get_used_rect], and [method rgbe_to_srgb].
+				[codeblock]
+				img.lock()
+				img.set_pixelv(Vector2(x, y), color) # Works
+				img.fill(dcolor) # Unlocks the image
+				img.set_pixelv(Vector2(x, y), color) # Does not have an effect
+				[/codeblock]
 			</description>
 		</method>
 		<method name="shrink_x2">