Comment 2 for bug 1212926

Revision history for this message
Martin Pitt (pitti) wrote :

Ah, I understand now. AFAICS, the easiest option is to just use the
lower 32 bits. This ought to work in practice as the heap is in a
single virtual segment anyway, so as long as we don't create many
hundred million widgets (which we couldn't handle anyway, FWIW) there
should be no collisions.

The alternative would be to use an increasing number like in -Qt.
When I previously wrote "there are no dynamic properties" I forgot
about qdata, which provides something like that. They are not type
save or introspectable, but that isn't necessary. Something like

  GQuark OBJ_ID = g_quark_from_static_string("AUTOPILOT_OBJECT_ID");
  static guint32 cur_obj_id = 1;

in the ap initialization, and then

  g_object_set_qdata (my_widget, OBJ_ID, (gpointer) cur_obj_id++);

  [...]

  guint32 id = (guint32) g_object_get_qdata (my_widget, OBJ_ID);