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 628253 - Interface properties not listed in a consistent order
Interface properties not listed in a consistent order
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gobject
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 626328 (view as bug list)
Depends on:
Blocks: 626328
 
 
Reported: 2010-08-29 15:55 UTC by Tristan Van Berkom
Modified: 2010-12-31 04:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (390 bytes, text/plain)
2010-08-29 18:41 UTC, Tristan Van Berkom
Details

Description Tristan Van Berkom 2010-08-29 15:55:36 UTC
This is a curious bug... it seems that g_object_class_list_properties() no longer
lists interface properties in a consistent order across invocations of libgobject.

This is the root cause of Glade bug 626328 (some interface properties 
saved in an inconsistent order).

Attached is a simple test case in C that should be compiled with
GTK+ master for a demonstration of the problem.

Just run the test a few times in a row and note that "use-action-appearance"
and "related-action" dont always get listed in the same order.
Comment 1 Severin Heiniger 2010-08-29 16:25:41 UTC
You seem to have forgotten to attach the test case.
Comment 2 Tristan Van Berkom 2010-08-29 18:41:04 UTC
Created attachment 169010 [details]
Test case
Comment 3 Matthias Clasen 2010-08-30 03:14:12 UTC
I don't think g_object_class_list_properties is meant to give you any guarantees about the order of properties. If you rely on an unchanging order, you should sort the returned list.
Comment 4 Tristan Van Berkom 2010-08-30 05:03:21 UTC
Could be it was not intended to be a consistent order, but
we've been relying on the order being consistent... its also very
curious (and even disturbing) that the exact same program 
performs differently across consecutive executions.

Also, property ordering in GtkBuilder output is not 100% arbitrary
(take GtkAdjustment:min/max/value for example) so using a new order; 
such as alphabetical order... could very well introduce some new bugs 
at GtkBuilder's show time (of course we try to special-case-order 
the output for cases where bug reports show that the natural order 
of _list_properties() is not good enough... but it's best to keep 
the special casing to a minimum).

Ideally ... I think _list_properties() should return properties
in the real order in which they were installed on the object class

In this way a widget can intentionally install properties in the
order in which it expects them to be set at g_object_new() time.

(actually... I thought they were always returned in their natural
order in the past... maybe something radically changed or they were 
always at least consistently ordered arbitrarily).
Comment 5 Tristan Van Berkom 2010-08-30 05:06:53 UTC
Hmmm I wonder if we can easily extract which numeric id was assigned
to each property by each class... in this way Glade could sort in a
meaningful order: ordered by id descending from the root class.
Comment 6 Matthias Clasen 2010-09-03 18:47:33 UTC
It becomes clear what is happening here if you make your testcase print out the owner_type and param_id:

GtkActivatable 0 use-action-appearance
GtkActivatable 0 related-action
GtkObject 1 user-data
GtkWidget 1 name
GtkWidget 2 parent
GtkWidget 3 width-request
GtkWidget 4 height-request
GtkWidget 5 visible
GtkWidget 6 sensitive
GtkWidget 7 app-paintable
GtkWidget 8 can-focus
GtkWidget 9 has-focus
GtkWidget 10 is-focus
GtkWidget 11 can-default
GtkWidget 12 has-default
GtkWidget 13 receives-default
GtkWidget 14 composite-child
GtkWidget 15 style
GtkWidget 16 events
GtkWidget 17 extension-events
GtkWidget 18 no-show-all
GtkWidget 19 has-tooltip
GtkWidget 20 tooltip-markup
GtkWidget 21 tooltip-text
GtkWidget 22 window
GtkWidget 23 double-buffered
GtkContainer 1 border-width
GtkContainer 2 resize-mode
GtkContainer 3 child
GtkButton 1 label
...

g_object_class_list_properties actually sorts by 'type depth' and param_id.
Unfortunately, overridden interface properties all get installed with param_id 0, so the sorting is noneffective for them.
Comment 7 Matthias Clasen 2010-09-03 18:55:44 UTC
commit c75429d0a0564c3620c6f72afea9838f661c4e88
Author: Matthias Clasen <mclasen@redhat.com>
Date:   Fri Sep 3 14:52:16 2010 -0400

    Make ordering for overridden interface properties consistent
    
    g_object_class_list_properties tries to sort the returned list of
    paramspecs by 'type depth' and param_id. But all the overridden
    interface properties have a param_id of 0, so they come out in
    a random order.
    
    Bug 628253.
Comment 8 Tristan Van Berkom 2010-12-31 04:37:19 UTC
*** Bug 626328 has been marked as a duplicate of this bug. ***