From 1b89a438c0144e7035ee92791725c9b3ccc32779 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Sat, 9 Jun 2018 14:00:05 -0700 Subject: [PATCH] Reenable finalizer to call rsvg_handle_free --- src/calls.jl | 7 +++++++ src/types.jl | 18 +++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/calls.jl b/src/calls.jl index 01712c4..6d4fc4a 100644 --- a/src/calls.jl +++ b/src/calls.jl @@ -67,3 +67,10 @@ end handle_new_from_data(data::AbstractString) """ handle_new_from_data(data::AbstractString) = handle_new_from_data(data::AbstractString,GError(0,0,0)) + +""" +handle_free(handle::RsvgHandle) +""" +function handle_free(handle::RsvgHandle) + ccall((:rsvg_handle_free,librsvg), Void, (RsvgHandle,), handle) +end diff --git a/src/types.jl b/src/types.jl index 525d63e..30bfee8 100644 --- a/src/types.jl +++ b/src/types.jl @@ -7,19 +7,19 @@ type RsvgHandle function RsvgHandle(ptr::Ptr{Void}) self = new(ptr) - #finalizer(self, destroy) + finalizer(self, destroy) self end end -# function destroy(handle::RsvgHandle) -# if handle.ptr == C_NULL -# return -# end -# Gtk.GLib.gc_unref(handle) -# handle.ptr = C_NULL -# nothing -# end +function destroy(handle::RsvgHandle) + if handle.ptr == C_NULL + return + end + handle_free(handle) + handle.ptr = C_NULL + nothing +end """ RsvgDimensionData is a simple struct of