Fix crashes in Gdk.Pixbuf.Savev

Patch from Bertrand Lorentz <bertrand.lorentz@gmail.com>

* gdk/Gdk.metadata: hide gdk_pixbuf_savev
* gdk/Pixbuf.custom: manually implement Savev to NullTerm the string[]
    parameters.

[Fixes #681111]
This commit is contained in:
Mike Kestner 2011-04-06 11:01:39 -05:00
parent 1752fca097
commit 571bd01356
2 changed files with 21 additions and 1 deletions

View file

@ -61,7 +61,7 @@
<attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='GetFormats']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='GetFormats']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='GetPixels']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='GetPixels']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='Save']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='Save']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='Savev']/*/*[@type='char**']" name="array">1</attr> <attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='Savev']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='SaveToBuffer']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='SaveToBuffer']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='SaveToBufferv']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='SaveToBufferv']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='SaveToCallback']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkPixbuf']/method[@name='SaveToCallback']" name="hidden">1</attr>

View file

@ -303,3 +303,23 @@
throw new GLib.GException (error); throw new GLib.GException (error);
} }
[DllImport("libgdk_pixbuf-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern unsafe bool gdk_pixbuf_savev(IntPtr raw, IntPtr filename, IntPtr type, IntPtr[] option_keys, IntPtr[] option_values, out IntPtr error);
public unsafe bool Savev(string filename, string type, string[] option_keys, string[] option_values) {
IntPtr error = IntPtr.Zero;
IntPtr native_filename = GLib.Marshaller.StringToPtrGStrdup (filename);
IntPtr native_type = GLib.Marshaller.StringToPtrGStrdup (type);
IntPtr[] native_option_keys = NullTerm (option_keys);
IntPtr[] native_option_values = NullTerm (option_values);
bool saved = gdk_pixbuf_savev(Handle, native_filename, native_type, native_option_keys, native_option_values, out error);
GLib.Marshaller.Free (native_filename);
GLib.Marshaller.Free (native_type);
ReleaseArray (native_option_keys);
ReleaseArray (native_option_values);
if (!saved)
throw new GLib.GException (error);
return saved;
}