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 534756 - Can't compile code with Time class as property
Can't compile code with Time class as property
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.3.x
Other All
: High normal
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on: 534781
Blocks:
 
 
Reported: 2008-05-25 12:35 UTC by Sebastian Pölsterl
Modified: 2008-12-17 23:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (636 bytes, text/plain)
2008-05-25 12:35 UTC, Sebastian Pölsterl
Details
Fixed constructor issue (983 bytes, text/plain)
2008-05-26 18:52 UTC, IainF
Details
Another test case (205 bytes, text/plain)
2008-07-11 21:54 UTC, Sebastian Pölsterl
Details

Description Sebastian Pölsterl 2008-05-25 12:35:05 UTC
See topic. Compiling gives:

$ valac -o testtime testtime.vala
testtime.c: In function 'timer_new':
testtime.c:31: error: incompatible type for argument 2 of 'g_value_set_pointer'
error: cc exited with status 256
Comment 1 Sebastian Pölsterl 2008-05-25 12:35:45 UTC
Created attachment 111497 [details]
Test case
Comment 2 IainF 2008-05-26 17:50:26 UTC
Is this just a namespace collision?

http://library.gnome.org/devel/glib/stable/glib-Timers.html

public class Test.Timer : GLib.Object {

    public Time TimeTM;

    public void run (int year, int month, int day, int hour, int minute) {
        this.TimeTM = this.create_time (year, month, day, hour, minute);
    }

// Etc ...

Works fine for me with valac 0.3.2.
Comment 3 Sebastian Pölsterl 2008-05-26 18:24:59 UTC
I'm using valac 0.3.2, too, on Ubuntu hardy, and it doesn't work for me.

I used "class Test.Timer" put the class in a namespace, didn't import GLib and used GLib.Time. The error is always present.
Comment 4 IainF 2008-05-26 18:52:11 UTC
Created attachment 111563 [details]
Fixed constructor issue

Hi,

Think I see the problem. In Vala, named public constructor can only set values. It can't call methods, only the special construct {} method can do that. See attached file for working example, it caught me out a couple of times too ;)
Comment 5 Sebastian Pölsterl 2008-05-26 19:41:24 UTC
It's obviously a hack, because I have to keep year, month, day, etc. around to use it again in construct. That way I wouldn't need the Time property anymore, because I already have all the information I need. According to Jürg using this.create_method in the named constructor should be fine.
Comment 6 IainF 2008-05-26 20:29:18 UTC
Been using run methods to sidestep the issue. I'm just going off observed behavior, obviously Jürg knows best. Should this one be closed and a new bug opened?

using GLib;

public class CreateMethod : Object {

  public int prop {get; construct;}

  CreateMethod (int p1, int p2) {
    this.prop = this.create_method (p1, p2);
  }

  public int create_method (int p1, int p2) {
    return p1 + p2;
  }

  public static void main () {
    var t = new CreateMethod (1, 1);
    message (t.prop.to_string ());
  }
}

CRITICAL **: create_method_create_method: assertion `IS_CREATE_METHOD (self)' failed

Comment 7 Sebastian Pölsterl 2008-05-26 21:12:45 UTC
self NULL at this point, making create_method static works. However, the problem with the Time property remains.
Comment 8 IainF 2008-05-26 21:30:52 UTC
Also the original error you reported is still a bug, arg 2 of generated code should be a g_pointer:

g_value_set_pointer (&__params_it->value, test_timer_create_time (self, year, month, day, hour, minute));

test_timer_create_time is generated as a struct, bug is not there in the test case I posted above because create_method is generated as a function and called with g_value_set_int.
Comment 9 Jürg Billeter 2008-05-28 20:32:37 UTC
Confirming, this should be fixed when we fix bug 534781
Comment 10 Sebastian Pölsterl 2008-07-11 21:54:54 UTC
Created attachment 114416 [details]
Another test case

I justed tried it with r1696 and a Time property with get and set. Code compiles, but when I run the program I get:
(process:28505): GLib-GObject-WARNING **: IA__g_object_notify: object class `Test' has no property named `StartTime'

This is a new error that didn't appear earlier.
Comment 11 Jürg Billeter 2008-12-17 23:51:41 UTC
2008-09-29  Jürg Billeter  <j@bitron.ch>

        * gobject/valaccodegenerator.vala:

        Don't use g_object_notify for non-GObject properties,
        fixes bug 548442

Fixed in r1815.

2008-10-10  Jürg Billeter  <j@bitron.ch>

	* gobject/valaccodecreationmethodbinding.vala:
	* gobject/valaccodemethodbinding.vala:

	Lift restriction on statements in creation methods of GObjects
	in preparation to support more flexible construction scheme

Fixed in r1825.