Skip to content

Commit c76c132

Browse files
committed
Add availability check in Image methods
1 parent 74462ed commit c76c132

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/uing/image.cr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module UIng
1010
end
1111

1212
def append(pixels, pixel_width : Int32, pixel_height : Int32, byte_stride : Int32) : Nil
13+
check_available
1314
LibUI.image_append(@ref_ptr, pixels, pixel_width, pixel_height, byte_stride)
1415
end
1516

@@ -19,7 +20,12 @@ module UIng
1920
@released = true
2021
end
2122

23+
private def check_available : Nil
24+
raise "Image has already been released" if @released
25+
end
26+
2227
def to_unsafe
28+
check_available
2329
@ref_ptr
2430
end
2531
end

0 commit comments

Comments
 (0)