GNOME Bugzilla – Bug 642885
Generated signature for local_command_line() vfunc, has one extra parameter.
Last modified: 2018-05-22 13:55:47 UTC
The virtual function local_command_line() signature in the .vapi file is: public virtual bool local_command_line ([CCode (array_length = false, array_null_terminated = true)] string[] arguments, int exit_status); The signature in the gtk3 documentation for the same function is: g_application_real_local_command_line (GApplication *application, gchar ***arguments, int *exit_status) I see two different problems: FIRST PROBLEM: When overriding the local_command_line virtual() function in my .vala file, the related generated code is: static gboolean cheese_main_real_local_command_line (GApplication* base, gchar** arguments, int arguments_length1, gint exit_status)" This generated function, has one argument more (int arguments_length1) which might not be there. SECOND PROBLEM: In the signature of the same function, in the .vapi files, the exit argument should be and out argument, that means: out int exit_status
commit 519d354ea4a8c508a46052be3ad60aab14a7898b Author: Jürg Billeter <j@bitron.ch> Date: Tue Feb 22 13:55:20 2011 +0100 gio-2.0: Fix g_application_local_command_line binding Fixes bug 642885. This commit fixes gchar ** vs. gchar *** and gint vs. gint * for the two parameters. However, you currently still need to explicitly annotate the parameter as null-terminated to avoid the extra parameter. This should get fixed as well but is easy to workaround for now: public override bool local_command_line ([CCode (array_length = false, array_null_terminated = true)] ref unowned string[] arguments, out int exit_status) { ... }
I applied the changes in the .vapi file and used the workaround you suggested, but when building, I get the following error in valac: ERROR:valaccodearraymodule.c:939:vala_ccode_array_module_real_get_array_length_cvalue: assertion failed: (_tmp20_) /bin/sh: line 1: 20560 Aborted (core dumped) /opt/gnome/bin/valac --thread --vapidir vapi --pkg config --pkg gtk+-3.0 --pkg gmodule-2.0 --pkg gee-1.0 --pkg clutter-1.0 --pkg clutter-gtk-1.0 --pkg gstreamer-0.10 --pkg libcanberra-gtk --pkg libcanberra --pkg eogthumbnav --pkg cheese-thumbview --pkg cheese-common --pkg clutter-tablelayout -C cheese-main.vala cheese-window.vala cheese-countdown.vala cheese-effects-manager.vala cheese-preferences.vala thumbview/cheese-thumb-view.c thumbview/cheese-thumbnail.c thumbview/eog-thumb-nav.c
Can you please provide a test case?
Patricia, did you solve this in the meantime? If not, maybe you can provide the test case.
Created attachment 255907 [details] test case app test case is attached if one ovrrides it like: (without a workaround) protected override bool local_command_line (ref unowned string[] arguments, out int exit_status) { ... option_context.parse (ref arguments); ... } it leads to a segmentation fault
commit ebfe7b7411f413a8631fec22e704a0d8921f4417 Author: Luca Bruno <lucabru@src.gnome.org> Date: Sun Sep 29 17:35:47 2013 +0200 codegen: Inherit array_{length,null_terminated} from base parameter First commit to start inheriting ccode attributes of parameters from base parameters of base methods. Partially fixes bug 642885. Now the code does not need the additional CCode when overriding. Next thing to fix is the "unowned string[] args = arguments;" workaround.
ebfe7b74 seems to be causing an error when attempting to build valac. Someone reported it on IRC, and I can reproduce (with a fresh checkout): VALAC arraylist.vala collection.vala hashmap.vala hashset.vala iterable.vala mapiterator.vala iterator.vala list.vala map.vala set.vala ** ERROR:arraylist.c:384:vala_array_list_real_get: assertion failed: (index >= 0 && index < _size) /bin/sh: line 1: 15611 Aborted (core dumped) /opt/gnome/bin/valac --disable-version-header -C --vapidir ./../vapi --pkg gobject-2.0 -H valagee.h --library gee arraylist.vala collection.vala hashmap.vala hashset.vala iterable.vala mapiterator.vala iterator.vala list.vala map.vala set.vala make[2]: *** [gee.vala.stamp] Error 134
(In reply to comment #7) > ebfe7b74 seems to be causing an error when attempting to build valac. Someone > reported it on IRC, and I can reproduce (with a fresh checkout): I've pushed a revert.
commit f3aeabaf16a5e9a9ad0aa5d64b18652c203c602e Author: Luca Bruno <lucabru@src.gnome.org> Date: Sun Sep 29 17:35:47 2013 +0200 codegen: Inherit array_{length,null_terminated} from base parameter First commit to start inheriting ccode attributes of parameters from base parameters of base methods. Partially fixes bug 642885. Attempt #2.
Passing "arguments" directly to option_context.parse() must error out, because there's no storage for the length. So that is actually not a workaround, it's the correct way to write the code.
-- 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/170.