FileChooserNative: allow null parent, free memory (#322)

* FileChooserNative: allow null parent, free memory

Also make consistent whitespaces, new lines.

* Re-run checks
This commit is contained in:
zii-dmg 2022-01-26 23:08:42 +03:00 committed by GitHub
parent 0915bf8076
commit c362ad1468
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -181,20 +181,14 @@ namespace Gtk {
static IntPtr FileChooserNativeCreate (string title, Gtk.Window parent, Gtk.FileChooserAction action, string accept_label, string cancel_label)
{
IntPtr native_title = GLib.Marshaller.StringToPtrGStrdup(title);
IntPtr native_accept_label = IntPtr.Zero;
if (accept_label != null)
native_accept_label = GLib.Marshaller.StringToPtrGStrdup (accept_label);
IntPtr native_cancel_label = IntPtr.Zero;
if (cancel_label != null)
native_cancel_label = GLib.Marshaller.StringToPtrGStrdup (cancel_label);
IntPtr native_accept_label = GLib.Marshaller.StringToPtrGStrdup(accept_label);
IntPtr native_cancel_label = GLib.Marshaller.StringToPtrGStrdup(cancel_label);
IntPtr raw = gtk_file_chooser_native_new(native_title, parent.Handle, (int) action, native_accept_label, native_cancel_label);
IntPtr raw = gtk_file_chooser_native_new(native_title, parent != null ? parent.Handle : IntPtr.Zero, (int) action, native_accept_label, native_cancel_label);
/*GLib.Marshaller.Free (native_title);
if (accept_label != null)
GLib.Marshaller.Free(native_title);
GLib.Marshaller.Free(native_accept_label);
if (cancel_label != null)
GLib.Marshaller.Free (native_cancel_label);*/
GLib.Marshaller.Free(native_cancel_label);
return raw;
}
@ -320,4 +314,3 @@ namespace Gtk {
}
}
}