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 624101 - In interfaces virtual properties are not hooked up in the generated c code
In interfaces virtual properties are not hooked up in the generated c code
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Code Generator
0.9.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-07-11 13:41 UTC by Aaron Andersen
Modified: 2018-05-22 13:41 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Aaron Andersen 2010-07-11 13:41:56 UTC
If you have a virtual property in an interface the function implementation is not hooked up in the iface_name_base_init function (virtual methods are, though).
Comment 1 Nate Stedman 2010-07-22 08:42:23 UTC
I'm having a similar (possibly the same issue):

Let's say I define an interface:

public interface Interface
{
    public string foo { get; set; }
}

And a class that inherits it:

public class Class : GLib.Object, Interface { }

Let's say I want to find the property for some reason, like this (obj is an instance of Class):

var prop = obj.get_class().find_property("foo");

For example I might want to do something like this (I'm just assuming this will compile, but you get the idea...):

public GLib.Value get_gvalue(GLib.Object, string prop)
{
    var type = obj.get_class().find_property(prop).value_type;
    return GLib.Value(type);
}

While this will work fine for any property contained within a class, it won't work with an interface/mixin, as shown above. The code will compile, but in the first example "type" will be null, and in the second the code will crash when run (for the same reason).

I think these are similar issues (possibly the same). frederik on #vala helped me find the potential issue:


03:47 < frederik> nate: i think a problem is that vala doesn't seem to install interface properties via 'g_object_interface_install_property': http://pastebin.com/rgz9Ye7U
03:47 < frederik> http://library.gnome.org/devel/gobject/stable/gobject-The-Base-Object-Type.html#g-object-interface-install-property
03:47 < frederik> http://library.gnome.org/devel/gobject/stable/gobject-The-Base-Object-Type.html#g-object-interface-find-property
...
04:01 < frederik> for a class 'g_object_class_install_property' is called: http://pastebin.com/LRUsDD1k
Comment 2 Adam Dingle 2011-04-25 22:52:03 UTC
Here's another symptom of what is probably the same problem.  If you try to set any property defined in an interface in Vala code, then GObject reports a warning that the property does not exist.  Here's a test program:

=== test.vala ===

int global;

interface Foo : Object {
    public int abc {
        get { return global; }
        set { global = value; }
    }
}

class Bar : Foo, Object { }

void main(string[] args) {
    Bar b = new Bar();
    b.abc = 7;
    debug("abc = %d", b.abc);
}

=== end ===

$ valac test.vala
$ ./test

(process:2782): GLib-GObject-WARNING **: g_object_notify: object class `Bar' has no property named `abc'
** (process:2782): DEBUG: test.vala:16: abc = 7
$
Comment 3 Michael 'Mickey' Lauer 2018-02-21 11:42:59 UTC
With Vala master the sample from https://bugzilla.gnome.org/show_bug.cgi?id=624101#c2 seems to work ok. Could you check whether the other cases are still open?
Comment 4 GNOME Infrastructure Team 2018-05-22 13:41:28 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/119.