GNOME Bugzilla – Bug 559647
[gtk+-2.0] Fields of Gtk.RecentData struct haven't the weak keyword
Last modified: 2009-09-13 18:39:54 UTC
Please describe the problem: Hello, Here a code of a gtk+-2.0.vapi file: public struct RecentData { public string display_name; public string description; public string mime_type; public string app_name; public string app_exec; [NoArrayLength] public string[] groups; public bool is_private; } In place of the correct code: public struct RecentData { public weak string display_name; public weak string description; public weak string mime_type; public weak string app_name; public weak string app_exec; [NoArrayLength] public weak string[] groups; public bool is_private; } I don't found where is the problem (the gi file seem correct), maybe in the vapigen program? Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Why do you think that the fields should be declared as weak? They are declared as gchar * in C, not as const gchar *, which usually indicates that the string should not be weak.
Because the generated C code use an unknow function (gtk_recent_data_destroy): http://bugzilla.gnome.org/show_bug.cgi?id=558446
I have found a better(?) way for fix this bug: [Compact] [CCode (has_type_id = false, cheader_filename = "gtk/gtk.h", free_function="g_free")] public class RecentData { public string display_name; public string description; public string mime_type; public string app_name; public string app_exec; [CCode (array_length = false)] public string[] groups; public bool is_private; } The problem seems to come from GTK+, the struct GtkRecentData don't have type id. But why valac call the function "destroy"?
Created attachment 142455 [details] [review] Mark RecentData fields as weak This is a temporary workaround until valac will generate the destroy function for all the used structs. With this patch applied you are forced to use a temporary variable and then assign that to the RecentData fields. Eg. Gtk.RecentData recent_data = Gtk.RecentData (); string name = project.name; //TEMP VAR REQUIRED string[] groups = new string[] { "vtg" }; //TEMP VAR REQUIRED recent_data.display_name = name; recent_data.groups = groups; recent_data.mime_type = "text/plain";
commit 2a2d12d5dbc17464b2228744fe9819189a23cced Author: Jürg Billeter <j@bitron.ch> Date: Sun Sep 13 20:39:18 2009 +0200 gtk+-2.0: Fix GtkRecentData binding Fixes bug 559647.