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 696424 - GSimpleAction.state property is not right
GSimpleAction.state property is not right
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gapplication
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-03-22 21:08 UTC by Allison Karlitskaya (desrt)
Modified: 2013-10-29 01:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GSimpleAction: don't allow changing state type (2.25 KB, patch)
2013-10-28 22:05 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Allison Karlitskaya (desrt) 2013-03-22 21:08:01 UTC
The 'state' property on GSimpleAction is a non-construct writable property.  The set_property() function looks like so:

    case PROP_STATE:
      action->state = g_value_dup_variant (value);
      break;


There are at least 3 problems here:

 - does not free the old value (probably because I thought it was construct-only
   when I implemented it)

 - does not do checks to make sure we are not changing the state type

 - probably state should be a construct property because during construction
   is the only time you should be allowed to set the state and be free of
   type checks
Comment 1 Allison Karlitskaya (desrt) 2013-10-28 22:05:53 UTC
Created attachment 258354 [details] [review]
GSimpleAction: don't allow changing state type

g_object_set() allowed us to bypass the usual checks that the state
doesn't change type and also leaked.

Fix that up by turning the state into a construct property (so that it
always gets set once during construction, even if only to NULL) and
then route the further sets through the C API so that they are subject
to the same checks.
Comment 2 Lars Karlitski 2013-10-29 00:02:25 UTC
Review of attachment 258354 [details] [review]:

Ok.