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 576492 - GtkBuilder does not respect G_PARAM_CONSTRUCT properties
GtkBuilder does not respect G_PARAM_CONSTRUCT properties
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkBuilder
unspecified
Other All
: Normal normal
: ---
Assigned To: Juan Pablo Ugarte
GtkBuilder maintainers
: 653047 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-03-23 21:38 UTC by Juan Pablo Ugarte
Modified: 2017-08-24 10:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Simple test case (3.86 KB, text/plain)
2009-03-23 21:40 UTC, Juan Pablo Ugarte
  Details
Better test case (5.32 KB, text/plain)
2011-06-22 19:07 UTC, Juan Pablo Ugarte
  Details
regresion fix (563 bytes, patch)
2011-06-22 19:16 UTC, Juan Pablo Ugarte
none Details | Review
Even better test case (7.04 KB, text/plain)
2011-06-22 23:07 UTC, Juan Pablo Ugarte
  Details
Regresion fix (1.73 KB, patch)
2011-06-22 23:15 UTC, Juan Pablo Ugarte
committed Details | Review

Description Juan Pablo Ugarte 2009-03-23 21:38:49 UTC
Every construct properties should be set before calling GObject:constructor and GObject::constructed methods, but this is not the case with GtkBuilder
Comment 1 Juan Pablo Ugarte 2009-03-23 21:40:33 UTC
Created attachment 131220 [details]
Simple test case

i have created a simple object with some debug output in both constructor and constructed methods and it instantiate an object using g_object_new() and another with GtkBuilder
Comment 2 Johan (not receiving bugmail) Dahlin 2009-03-26 01:27:08 UTC
Something like this should probably do it:

Index: gtk/gtkbuilder.c
===================================================================
--- gtk/gtkbuilder.c	(revision 22374)
+++ gtk/gtkbuilder.c	(working copy)
@@ -280,7 +280,8 @@
       if (G_IS_PARAM_SPEC_OBJECT (pspec) &&
           (G_PARAM_SPEC_VALUE_TYPE (pspec) != GDK_TYPE_PIXBUF))
         {
-          if (pspec->flags & G_PARAM_CONSTRUCT_ONLY)
+          if (pspec->flags & G_PARAM_CONSTRUCT ||
+              pspec->flags & G_PARAM_CONSTRUCT_ONLY)
             {
               GObject *object;
               object = gtk_builder_get_object (builder, prop->data);

No time to compile/add test right now.
Comment 3 Matthias Clasen 2011-06-01 05:39:44 UTC
Looks right to me.
Comment 4 Juan Pablo Ugarte 2011-06-01 20:54:32 UTC
Geez I completely forgot I reported this bug.
Matthias, I can test and commit the proposed patch if you like.
Comment 5 Matthias Clasen 2011-06-03 13:21:03 UTC
That would be great
Comment 6 Juan Pablo Ugarte 2011-06-03 18:20:24 UTC
Fixed in master, gtk-2-24 and gtk-3-0 branches

http://git.gnome.org/browse/gtk+/commit/?id=f430a76f10d1b7790d83006f9817890960063ed8
Comment 7 Nick Schermer 2011-06-19 10:50:01 UTC
This breaks the xfce4-panel. Getting messages like "Gtk-WARNING **: Failed to get constuct only property adjustment of leave-opacity-scale with value `leave-opacity'"

http://git.xfce.org/xfce/xfce4-panel/plain/panel/panel-preferences-dialog.glade
Comment 8 Juan Pablo Ugarte 2011-06-20 22:26:58 UTC
I think this just exposed a different bug, before this patch those properties where not even set up, now that they are, object properties seems to fail if the object is not defined before its used.
I always though GtkBuilder dereferenced setting up object props to the end but for some reason its not.
So if you move all those objects like `leave-opacity` to the beginning of the file the warnings go away.
Comment 9 Nick Schermer 2011-06-21 05:46:26 UTC
Yeah indeed that works fine. However maybe this bug should be reassigned to glade to fix the saving.
Comment 10 Nick Schermer 2011-06-21 22:21:40 UTC
I've released new versions of the Xfce packages that were affected by this change.

However I'd like show my concern that fixes like these are landing in the 2.24 branch. Nothing was broken (the previous glade files worked fine) and although I agree this "does the right thing", imho it does not qualify as critical bug fixes or regressions.
Given the fact that git-gtk2 is less tested now gtk3 is around, it's easier for regressions to slip through... Hope this will be taken in consideration when future patches are allowed in gtk-2.24.
Comment 11 Matthias Clasen 2011-06-21 23:48:59 UTC
(In reply to comment #9)
> Yeah indeed that works fine. However maybe this bug should be reassigned to
> glade to fix the saving.

No, this is still a gtkbuilder bug.

(In reply to comment #10)
> I've released new versions of the Xfce packages that were affected by this
> change.
> 
> However I'd like show my concern that fixes like these are landing in the 2.24
> branch. Nothing was broken (the previous glade files worked fine) and although
> I agree this "does the right thing", imho it does not qualify as critical bug
> fixes or regressions.
> Given the fact that git-gtk2 is less tested now gtk3 is around, it's easier for
> regressions to slip through... Hope this will be taken in consideration when
> future patches are allowed in gtk-2.24.

I'm sorry that you were inconvenienced by this.
Here is how you can help avoiding this kind of fallout in the future:
Write a patch for gtk/tests/builder.c adding a test case for the problem you've experienced. That should make it a) much easier to fix and b) prevent regressions in the future.
Comment 12 Juan Pablo Ugarte 2011-06-22 19:07:48 UTC
Created attachment 190466 [details]
Better test case

I added a new object construct only property to the test case.
Comment 13 Juan Pablo Ugarte 2011-06-22 19:16:04 UTC
Created attachment 190469 [details] [review]
regresion fix

Construct only object properties can not be delayed because... well they are construct only which means that it will fail if the object is not already constructed.

So we either need to make sure that glade serializes objects that are referenced in a construct only property first or we need to fix GtkBuilder to make it construct the object property instead of just complaining.

In either case we will have to handle circular dependencies, right?
but i guess in this case it makes sense to just complain! :D
Comment 14 Juan Pablo Ugarte 2011-06-22 23:07:18 UTC
Created attachment 190477 [details]
Even better test case
Comment 15 Juan Pablo Ugarte 2011-06-22 23:15:12 UTC
Created attachment 190478 [details] [review]
Regresion fix

This patch makes builder do not delay construct properties that can be resolved (so construct is respected when possible) and skip construct only props that can not.
Comment 16 Matthias Clasen 2011-06-27 20:36:40 UTC
Review of attachment 190478 [details] [review]:

Looks like thats about the best we can do here.
Comment 17 Juan Pablo Ugarte 2011-06-29 15:33:22 UTC
Review of attachment 190478 [details] [review]:

Committed in master 3.0 and 2.24 branches
http://git.gnome.org/browse/gtk+/commit/?id=ea81c710d0c0df31035297c4be6ca50b196560c6
Comment 18 Daniel Boles 2017-08-24 10:59:28 UTC
*** Bug 653047 has been marked as a duplicate of this bug. ***