Skip to content

Commit 6cb82d1

Browse files
committed
Add the number of points for the ConvexShape on the construct to prevent segfault if the user forgot to call set_point_count
1 parent bb7e5a2 commit 6cb82d1

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/rsfml/graphics/convex_shape.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,21 @@ impl<'self> ConvexShape<'self> {
109109
/**
110110
* Create a new convex shape
111111
*
112+
* # Arguments
113+
* * points_count - The number of point for the convex shape
114+
*
112115
* Return a new convexShape object
113116
*/
114117
#[fixed_stack_segment] #[inline(never)]
115-
pub fn new() -> Option<ConvexShape<'self>> {
118+
pub fn new(points_count : uint) -> Option<ConvexShape<'self>> {
116119
let shape = unsafe { ffi::sfConvexShape_create() };
117120
if ptr::is_null(shape) {
118121
None
119122
}
120123
else {
124+
unsafe {
125+
ffi::sfConvexShape_setPointCount(shape, points_count as c_uint);
126+
}
121127
Some(ConvexShape {
122128
convex_shape : shape,
123129
texture : None
@@ -128,17 +134,22 @@ impl<'self> ConvexShape<'self> {
128134
/**
129135
* Create a new convex shape with a texture
130136
*
137+
* # Arguments
138+
* * texture - The texture to apply to the convex shape
139+
* * points_count - The number of point for the convex shape
140+
*
131141
* Return a new convexShape object
132142
*/
133143
#[fixed_stack_segment] #[inline(never)]
134-
pub fn new_with_texture(texture : &'self Texture) -> Option<ConvexShape<'self>> {
144+
pub fn new_with_texture(texture : &'self Texture, points_count : uint) -> Option<ConvexShape<'self>> {
135145
let shape = unsafe { ffi::sfConvexShape_create() };
136146
if ptr::is_null(shape) {
137147
None
138148
}
139149
else {
140150
unsafe {
141151
ffi::sfConvexShape_setTexture(shape, texture.unwrap(), SFTRUE);
152+
ffi::sfConvexShape_setPointCount(shape, points_count as c_uint)
142153
}
143154
Some(ConvexShape {
144155
convex_shape : shape,

src/rsfml/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
uuid = "4F3334F2-A32B-4460-A63A-9B56C98D1D78",
3333
url = "http://https://github.com/JeremyLetang/rust-sfml")];
3434

35-
#[comment = "Rust binding for sfml"];
35+
#[desc = "Rust binding for sfml"];
3636
#[license = "Zlib/png"];
3737
#[crate_type = "lib"];
3838

0 commit comments

Comments
 (0)