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 648416 - g_app_info_create_from_commandline ignores SUPPORTS_STARTUP_NOTIFICATION
g_app_info_create_from_commandline ignores SUPPORTS_STARTUP_NOTIFICATION
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.28.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-04-21 19:17 UTC by Michael Terry
Modified: 2011-04-25 12:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (396 bytes, text/plain)
2011-04-21 19:19 UTC, Michael Terry
  Details
Proposed patch (1.12 KB, patch)
2011-04-21 19:21 UTC, Michael Terry
none Details | Review
Standard style (1.10 KB, patch)
2011-04-21 20:46 UTC, Michael Terry
accepted-commit_now Details | Review

Description Michael Terry 2011-04-21 19:17:53 UTC
g_app_info_create_from_commandline does the following to check for STARTUP_NOTIFICATION:

  info->startup_notify = flags & G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION;

But info->startup_notify was declared like so:

  guint startup_notify  : 1;

While G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION was declared like so:

  G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION  = (1 << 2)

So what the first line of code does is try to assign the number 4 to a field that can only hold 0 or 1.  Thus guaranteeing that no such AppInfo object can support startup notification.

I'll attach a short vala test case and a patch.
Comment 1 Michael Terry 2011-04-21 19:19:07 UTC
Created attachment 186447 [details]
Test case

Compile with: valac --pkg=gtk+-3.0 startup.vala
Run with: ./startup

You should see a spinner if glib is behaving correctly (we're lying here to glib, so you'll see the spinner until it times out, but you should see it).
Comment 2 Michael Terry 2011-04-21 19:21:18 UTC
Created attachment 186448 [details] [review]
Proposed patch
Comment 3 Christian Persch 2011-04-21 20:37:57 UTC
Usually in glib, gtk etc this is written like so:

bit_in_bitfield = (flags & FLAG) != 0;
Comment 4 Michael Terry 2011-04-21 20:46:37 UTC
Created attachment 186452 [details] [review]
Standard style

Ah, OK.  Here's one with the recommended style.  Thanks!
Comment 5 Matthias Clasen 2011-04-25 10:55:48 UTC
Review of attachment 186452 [details] [review]:

Looks good otherwise.

::: gio/gdesktopappinfo.c
@@ +1659,2 @@
   info->hidden = FALSE;
   if (flags & G_APP_INFO_CREATE_SUPPORTS_URIS)

Should probably add the '!= 0' in line 1660 as well, while we are at it.
Comment 6 Michael Terry 2011-04-25 12:35:26 UTC
commit a330c2f19f5086986940e57bdf1e7db651db725c
Author: Michael Terry <michael.terry@canonical.com>
Date:   Mon Apr 25 08:29:35 2011 -0400

    Don't ignore SUPPORTS_STARTUP_NOTIFICATION for commandline GAppInfos
    
    https://bugzilla.gnome.org/show_bug.cgi?id=648416