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 726623 - gtk_application_set_accels_for_action(): allow null accels
gtk_application_set_accels_for_action(): allow null accels
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Class: GtkApplication
3.11.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-03-18 11:25 UTC by Murray Cumming
Modified: 2016-05-24 15:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
app: allow NULL accels param for set_accels_for_action() (3.35 KB, patch)
2016-05-24 12:38 UTC, Sébastien Wilmet
none Details | Review
app: allow NULL accels param for set_accels_for_action() (3.37 KB, patch)
2016-05-24 12:47 UTC, Sébastien Wilmet
none Details | Review

Description Murray Cumming 2014-03-18 11:25:34 UTC
gtk_application_set_accels_for_action() does not check for a null accels array and always tries to dereference it to get accels[0]:
https://git.gnome.org/browse/gtk+/tree/gtk/gtkapplication.c#n1487

I'd patch in a g_return_if_fail() check, but maybe you want to allow NULL to unset the accels and then mention that in the documentation.
Comment 1 Sébastien Wilmet 2016-05-24 12:38:38 UTC
Created attachment 328433 [details] [review]
app: allow NULL accels param for set_accels_for_action()

For convenience, to avoid declaring a variable just to unset accels.

gtk_application_accels_set_accels_for_action() already supported a NULL
accels.
Comment 2 Sébastien Wilmet 2016-05-24 12:47:44 UTC
Created attachment 328434 [details] [review]
app: allow NULL accels param for set_accels_for_action()

For convenience, to avoid declaring a variable just to unset accels.

gtk_application_accels_set_accels_for_action() already supported a NULL
accels.
Comment 3 Sébastien Wilmet 2016-05-24 12:49:24 UTC
Forgot the "since 3.22" in the first patch.
Comment 4 Matthias Clasen 2016-05-24 14:56:38 UTC
I hate this constant push to conflate NULL with all sorts of pointer types.

You don't need a variable either:

gtk_application_accels_set_accels_for_action(app, action, (const char **) { NULL, NULL }); 

works just fine in modern C.
Comment 5 Sébastien Wilmet 2016-05-24 15:38:01 UTC
Ok, NULL to unset something is not awkward to me, but as you want.