[Vala] GLib-GObject-WARNING but code appears to work



Greetings,

I am building a simple structure driven json reader, and in the process
construct objects from Type values.  The construction appears to work
correctly, in that the instances are created, have the expected fields that
can be found by find_property, and end up with values from the json string
correctly assigned.  My concern is a warning message generated when the
following code is executed:

Object child = Object  new (e_type);

Which results in a message:
 GLib-GObject-WARNING **: cannot retrieve class for invalid (unclassed)
type '(null)'

A typical type generating this warning on creation via the above code is:

public class AxleInfo : GLib.Object {

  public int pos {get; set; }
  public int weight {get; set; }
  public bool twin {get; set; }

  public AxleInfo(int pos, int weight, bool twin = false) {
    this.pos = pos;
    this.weight = weight;
    this.twin = twin;
  }
}

The e_type value is consistent with the typeof (AxleInfo) value, and is
obtained via:

              Gee.Collection<Object> arr = (Gee.Collection<Object>)current;
              Type e_type = arr.element_type;

So, is there something I should be doing to register this type, or some
other step I'm missing?
Is the "element_type" value returned the correct parameter to pass to
Object  new to create a new array element?
What does the error message mean in practice?  I have not had any luck so
far in finding an explanation.

Regards,

Andrew Lees


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]