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 564425 - Creation of GtkSourceStyle objects assigns wrong values to "xxx-set" properties
Creation of GtkSourceStyle objects assigns wrong values to "xxx-set" properties
Status: RESOLVED OBSOLETE
Product: gtksourceview
Classification: Platform
Component: General
2.4.x
Other All
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2008-12-13 22:30 UTC by Mike Spivey
Modified: 2021-07-05 11:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (638 bytes, text/x-csrc)
2008-12-13 22:31 UTC, Mike Spivey
Details

Description Mike Spivey 2008-12-13 22:30:04 UTC
Please describe the problem:
Attempting to construct a GtkSourceStyle object via g_object_new with (say) bold=true results in an object where bold=true but bold-set=false.  Explicitly setting bold-set=true has no effect either.

Documentation is inexplicit about whether it is necessary to set bold-set=true also, but it seems from the code that this is not needed.

Steps to reproduce:
See attached test case

Actual results:
Output is 1 0 / 1 0


Expected results:
Expected 1 1 / 1 1

Does this happen every time?
Yes

Other information:
gtksourcestyle.c line 189 reads:

#define UNSET_MASK(style,name) (style)->mask &= (GTK_SOURCE_STYLE_USE_##name)

Comparing with the previous line, I suspect it should read 

#define UNSET_MASK(style,name) (style)->mask &= ~(GTK_SOURCE_STYLE_USE_##name)

but don't have time to set up the build and test this.

The documentation for g_object_new says that it sets all parameters not explicitly mentioned to their default values.  You'll know better than me what effect that might have, with or without the patch I've suggested.

GtkSourceStyleManager doesn't set the properties via g_object_new, because "nobody will know the difference".  Ha!

With best wishes,

-- Mike
Comment 1 Mike Spivey 2008-12-13 22:31:12 UTC
Created attachment 124608 [details]
Test case
Comment 2 Mike Spivey 2008-12-13 22:32:40 UTC
This is my third bug in three days.  Do I get bonus points?  Or should I take a day off tomorrow?

Best wishes,

-- Mike
Comment 3 Yevgen Muntyan 2008-12-13 22:35:34 UTC
You do get half a gazillion bonus points. Please don't stop there.
Comment 4 Mike Spivey 2008-12-14 00:02:53 UTC
I did try the proposed patch: it changes the results of the test to 1 0 / 1 1.  In other words, it now works to set both "bold" and "bold-set" explicitly on construction, but setting just "bold" leaves "bold-set" as false, despite the code that aims to set "bold-set" as a side-effect of setting "bold".

My guess is that if "bold-set" is not set explicitly, then setting "bold" makes it 1, and then g_new_object sets it back to 0.  It seems that the plan to set "bold-set" implicitly will not work in the face of the gobject convention of setting all properties that are not mentioned in the g_new_object call to their default values.  A print statement at the top of gtk_source_style_set_property confirms that this is what is happening.

The next step I leave to you!  Perhaps the simplest move would be to nuke the implicit setting code, and document that "bold-set" etc. must be set explicitly.

-- Mike
Comment 5 Mike Spivey 2008-12-14 14:50:32 UTC
In point of fact, this interface is currently useless, as there's nothing you can actually do with a SourceStyle after you've created it.

It's only people like me -- implementing a language binding for Objective Caml -- who will ever call this constructor, and then only from unit tests!

-- Mike
Comment 6 Yevgen Muntyan 2008-12-16 18:59:04 UTC
You are right, it's some piece of shitty code. UNSET_MASK is buggy, the whole thing is buggy. I kind of fixed it, i.e. I made g_object_new(GTK_TYPE_SOURCE_STYLE, "bold", TRUE, NULL) work. But "bold-set" won't do anything anymore, it prints a warning instead (it has to stay WRITABLE for compatibility).

Comment 7 Yevgen Muntyan 2008-12-16 19:02:51 UTC
Oops, it's still broken. This interface just can't work. CONSTRUCT just isn't a right thing to use here. I am reverting the last commit, and leave this bug to rot for a while.
Comment 8 GNOME Infrastructure Team 2021-07-05 11:02:26 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/gtksourceview/-/issues/

Thank you for your understanding and your help.