diff --git a/examples/clock/clock.v b/examples/clock/clock.v index 61e4430e4a..b111850f79 100644 --- a/examples/clock/clock.v +++ b/examples/clock/clock.v @@ -88,11 +88,12 @@ fn on_frame(mut app App) { } // Rotate a polygon round the centerpoint +[manualfree] fn draw_convex_poly_rotate(mut ctx gg.Context, dpi_scale f32, points []f32, c gx.Color, angle f32) { sa := math.sin(math.pi * angle / 180.0) ca := math.cos(math.pi * angle / 180.0) - mut rotated_points := []f32{} + mut rotated_points := []f32{cap: points.len} for i := 0; i < points.len / 2; i++ { x := points[2 * i] y := points[2 * i + 1] @@ -102,6 +103,7 @@ fn draw_convex_poly_rotate(mut ctx gg.Context, dpi_scale f32, points []f32, c gx rotated_points << (yn + center) * dpi_scale } ctx.draw_convex_poly(rotated_points, c) + unsafe { rotated_points.free() } } fn (mut app App) resize() { @@ -133,7 +135,7 @@ fn on_event(e &gg.Event, mut app App) { .q { println('Good bye.') // do we need to free anything here? - exit(0) + app.gg.quit() } else {} } diff --git a/vlib/gg/gg.v b/vlib/gg/gg.v index 408402ffe6..1959f39833 100644 --- a/vlib/gg/gg.v +++ b/vlib/gg/gg.v @@ -237,6 +237,7 @@ fn gg_cleanup_fn(user_data voidptr) { if g.config.cleanup_fn != voidptr(0) { g.config.cleanup_fn(g.config.user_data) } + gfx.shutdown() } fn gg_fail_fn(msg &char, user_data voidptr) {