Merge lp:~ballogy/bamf/fix-current-desktop into lp:bamf/0.4

Proposed by Balló György
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 504
Merged at revision: 523
Proposed branch: lp:~ballogy/bamf/fix-current-desktop
Merge into: lp:bamf/0.4
Diff against target: 38 lines (+11/-2)
1 file modified
src/bamf-matcher.c (+11/-2)
To merge this branch: bzr merge lp:~ballogy/bamf/fix-current-desktop
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+137762@code.launchpad.net

Description of the change

This change fixes the following two problems what I experienced while using BAMF on Arch Linux:

1. Fix desktop file table if XDG_CURRENT_DESKTOP environment variable is not available.

Using the vanilla gnome-session without Ubuntu patches, the XDG_CURRENT_DESKTOP is not specified. In this case, all desktop files are ignored which contain the OnlyShowIn property. This isn't the expected behavior, because many GNOME desktop files are ignored in a GNOME session, e.g. nautilus, control center entries. To fix this issue, all desktop files should be added to the desktop file table if no XDG_CURRENT_DESKTOP specified.

2. Fix a critical warning if an empty Exec= line specified in a desktop file.

Without this extra check, the following critical message displayed in this case (e.g. with the unity-scope-gdocs.desktop file):

** (bamfdaemon:20159): CRITICAL **: insert_data_into_tables: assertion `exec' failed

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Thanks for your patch.

27 - if (!exec)
28 + if (!exec || exec[0] == '\0')

In the case that (exec[0] == '\0') you also need to free it.

Overall that's fine. Would you mind also to add a small test case into test-matcher.c?

Revision history for this message
Balló György (ballogy) wrote :

Unfortunately, I don't know how to write tests.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

György: if you look at tests/bamfdaemon/test-matcher.c you could find some examples of how to get that... You could try to do a test like "test_load_desktop_file", but unsetting the XDG_CURRENT_DESKTOP variable before running it.

Revision history for this message
Balló György (ballogy) wrote :

Sorry, I can't write the test.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Mh, ok... I can do it, but could you please at least fix the memory leak?

lp:~ballogy/bamf/fix-current-desktop updated
504. By Balló György

Fix memory leak

Revision history for this message
Balló György (ballogy) wrote :

Yes, now I fixed the memory leak.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ok, thanks

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/bamf-matcher.c'
2--- src/bamf-matcher.c 2013-01-29 19:06:11 +0000
3+++ src/bamf-matcher.c 2013-02-16 22:23:19 +0000
4@@ -821,6 +821,7 @@
5 GHashTable *desktop_class_table)
6 {
7 GDesktopAppInfo *desktop_file;
8+ const char *current_desktop;
9 char *exec;
10 char *path;
11 GString *desktop_id; /* is ok... really */
12@@ -834,7 +835,9 @@
13 return;
14 }
15
16- if (!g_desktop_app_info_get_show_in (desktop_file, g_getenv ("XDG_CURRENT_DESKTOP")))
17+ current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
18+
19+ if (current_desktop && !g_desktop_app_info_get_show_in (desktop_file, current_desktop))
20 {
21 g_object_unref (desktop_file);
22 return;
23@@ -842,9 +845,15 @@
24
25 exec = g_strdup (g_app_info_get_commandline (G_APP_INFO (desktop_file)));
26
27- if (!exec)
28+ if (!exec || exec[0] == '\0')
29 {
30 g_object_unref (desktop_file);
31+
32+ if (exec)
33+ {
34+ g_free (exec);
35+ }
36+
37 return;
38 }
39

Subscribers

People subscribed via source and target branches