Re: [Vala] Struct property bug: get, but not set
- From: jryan <jryan curious-os com>
- To: vala-list <vala-list gnome org>
- Subject: Re: [Vala] Struct property bug: get, but not set
- Date: Mon, 02 May 2011 01:13:33 -0400
Excerpts from Nor Jaidi Tuah's message of 2011-05-01 23:32:19 -0400:
The following displays 0 for button.color.red.
Expected: 100.
void main (string[] args) {
Gtk.init (ref args);
var button = new Gtk.ColorButton ();
button.color.red = 100; /*1*/
debug ("%d", button.color.red);
}
Line /*1*/ is compiled to:
gtk_color_button_get_color (button, &_tmp1_);
_tmp1_.red = (guint16) 100;
There is no set access to button.color at all!
Is this a known bug?
hand
Nor Jaidi Tuah
Not a bug.
Explanation:
http://bugzilla.gnome.org/show_bug.cgi?id=621787
I think you're going to have to create a new Color:
using Gtk;
void main(string[] args) {
Gtk.init(ref args);
var color = Color() { pixel=0, red=100, green=0, blue=0 };
var button = new Gtk.ColorButton.with_color(color);
debug(@"$(button.color.red)");
}
I think this is because structs are passed by value,
and not by reference, so it creates a temporary struct
(a shallow copy) when using the getter, then you are setting
the red of that temporary struct, not actually changing
the button's color struct.
--
Jonathan Ryan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]