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 659305 - GObject properties, null terminated string array doesn't work
GObject properties, null terminated string array doesn't work
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Code Generator: GObject
unspecified
Other Linux
: Normal normal
: 1.0
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-09-17 09:13 UTC by Lucas Baudin
Modified: 2018-05-22 14:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Code to show the bug (328 bytes, text/x-vala)
2011-09-17 09:13 UTC, Lucas Baudin
Details

Description Lucas Baudin 2011-09-17 09:13:34 UTC
Created attachment 196792 [details]
Code to show the bug

If a gobject property is a null terminated array of string, it behaves as if it was not null terminated (see attached code, that I compile with "valac -H header.h -C header.vala")

It produces C functions like:
void test_array_set_null_terminated_array (TestArray* self, gchar** value, int value_length1);

But it is not logical, it should produce functions like:
void test_array_set_null_terminated_array (TestArray* self, gchar** value);

The length argument is not needed since the array must be null terminated.
Comment 1 Luca Bruno 2011-09-20 10:28:40 UTC
Even if the array is null terminated, it's nothing bad to have a length. So the problem is not that vala adds the length, but it's whether you explicitly want to _not_ have a length and vala fails. I assume the bug is about the latter.
Comment 2 Lucas Baudin 2011-09-20 16:58:56 UTC
Hum ok, my problem is that I want to make a C API which already exists (we wanted to do some modifications to GtkAbotuDialog in Vala, with the function set_authors for instance, we are stuck). But I think vala should just not put the length when the array is null terminated... or maybe there is another flag to say to valac that we don't want it ?
Comment 3 Luca Bruno 2011-09-20 17:44:31 UTC
Using [CCode (array_length = false, array_null_terminated = true)] should work for bindings. Can you confirm?
Comment 4 Lucas Baudin 2011-09-20 18:46:50 UTC
Yes, it works for the .vapi. (but as shown in the example code, it doesn't work to generate .h)
Comment 5 Travis Reitter 2011-11-23 16:23:53 UTC
This bug is particularly nasty in that it can lead to very hard-to-debug situations.

I've got a constructor like:

public Foo (string[] some_str_array)
{
  Object (str_array: some_str_array);
}

In some tests, the value of str-array was turning out to be {"abc", "def", "123", "456"}. The first two values were from a pre-defined array of common valid values. But the second two values were from a completely different array that wasn't even being used in the construction of the object.

So I burned a bit of time on this until I realized that it was a freak accident due to some_str_array not being NULL-terminated,
Comment 6 Daniel Espinosa 2017-03-13 14:02:38 UTC
This is a limitation of Vala.

If property use a GLib collection, like GQueue, or Gee one, this shouldn't be a problem.

So I would like to suggest this bug to be  changed to enhancement and Target 1.2 instead.
Comment 7 GNOME Infrastructure Team 2018-05-22 14:09:55 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/232.