After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 559647 - [gtk+-2.0] Fields of Gtk.RecentData struct haven't the weak keyword
[gtk+-2.0] Fields of Gtk.RecentData struct haven't the weak keyword
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings
0.5.x
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-06 19:25 UTC by sanpi
Modified: 2009-09-13 18:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Mark RecentData fields as weak (1.02 KB, patch)
2009-09-04 07:46 UTC, Andrea Del Signore
none Details | Review

Description sanpi 2008-11-06 19:25:37 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:
Comment 1 Jürg Billeter 2008-12-16 22:15:19 UTC
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.
Comment 2 sanpi 2008-12-16 22:23:50 UTC
Because the generated C code use an unknow function (gtk_recent_data_destroy): http://bugzilla.gnome.org/show_bug.cgi?id=558446
Comment 3 sanpi 2009-08-26 15:11:21 UTC
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"?
Comment 4 Andrea Del Signore 2009-09-04 07:46:32 UTC
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";
Comment 5 Jürg Billeter 2009-09-13 18:39:54 UTC
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.