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 632116 - don't clobber gerrors
don't clobber gerrors
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2010-10-14 03:59 UTC by William Jon McCann
Modified: 2010-10-23 20:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Don't pass in errors that then get set and then overwritten (1.98 KB, patch)
2010-10-14 04:00 UTC, William Jon McCann
none Details | Review
Make color constants work without warnings (3.78 KB, patch)
2010-10-14 17:48 UTC, Owen Taylor
committed Details | Review

Description William Jon McCann 2010-10-14 03:59:47 UTC
Reproduce by running mutter-theme-viewer from a terminal:
mutter-theme-viewer --g-fatal-warnings Adwaita
Comment 1 William Jon McCann 2010-10-14 04:00:25 UTC
Created attachment 172322 [details] [review]
Don't pass in errors that then get set and then overwritten

The code was clearing the errors in the case where they weren't set
and the cascading if statements were clobbering existing errors in
the failure cases.
Comment 2 Owen Taylor 2010-10-14 17:48:14 UTC
Created attachment 172371 [details] [review]
Make color constants work without warnings

Don't really like that your patch will complain about '0..' as a bad color
value. I think the attached is a bit better - it goes back more to the
way that the code was structured before the bug was originally introduced.
Comment 3 Dan Winship 2010-10-18 14:46:29 UTC
Comment on attachment 172371 [details] [review]
Make color constants work without warnings

>+      /* We don't know how a a constant is going to be used, so we have guess its
>+       * type from its contents:
>+       *
>+       *  - Starts like a number and contains a '.': float constant
>+       *  - Starts like a number and doesn't contain a '.': int constant
>+       *  - Starts with anything else: a color constant.
>+       *    (colors always start with # or a letter)
>+       */

This doesn't seem to be true; parse_positive_integer() accepts named constants in addition to numbers. (And it's probably a bug that parse_double() *doesn't*.)

>+      if (value[0] == '.' || value[0] == '-' || (value[0] >= '0' && value[0] <= '9'))

in theory, a number can also start with '+'

>+          if (strchr (value, '.'))

the existing code would also accept scientific notation floats (1e5), though that's probably unintentional and maybe undesireable.
Comment 4 Owen Taylor 2010-10-23 20:17:37 UTC
(In reply to comment #3)
> (From update of attachment 172371 [details] [review])
> >+      /* We don't know how a a constant is going to be used, so we have guess its
> >+       * type from its contents:
> >+       *
> >+       *  - Starts like a number and contains a '.': float constant
> >+       *  - Starts like a number and doesn't contain a '.': int constant
> >+       *  - Starts with anything else: a color constant.
> >+       *    (colors always start with # or a letter)
> >+       */
> 
> This doesn't seem to be true; parse_positive_integer() accepts named constants
> in addition to numbers. (And it's probably a bug that parse_double()
> *doesn't*.)

I'm a little skeptical that it's useful to be able to set a constant to be exactly equal to another constant, but not be able to set a constant to be able to be an expression based on another constant

And the fact that this worked only for integers and colors but not doubles makes me think it was completely accidental. So, I'm willing to risk that no themes were relying on that. (True for the small set of themes on my system.)

> >+      if (value[0] == '.' || value[0] == '-' || (value[0] >= '0' && value[0] <= '9'))
> 
> in theory, a number can also start with '+'

Hmm, didn't know that strtod accepted that.
 
> >+          if (strchr (value, '.'))
> 
> the existing code would also accept scientific notation floats (1e5), though
> that's probably unintentional and maybe undesireable.

The old code was:

-      if (strchr (value, '.') && parse_double (value, &dval, context, error))

I'll push the patch with the addition of '+' support, and hopefully we won't break too many obscure themes that happened to stumble on the specifying-integer-constant-as-integer-constant bug.