Merge lp:~charlesk/indicator-session/lp-957342 into lp:indicator-session/0.4

Proposed by Charles Kerr on 2012-03-16
Status: Merged
Approved by: Charles Kerr on 2012-03-19
Approved revision: 251
Merged at revision: 250
Proposed branch: lp:~charlesk/indicator-session/lp-957342
Merge into: lp:indicator-session/0.4
Diff against target: 59 lines (+9/-14)
2 files modified
src/device-menu-mgr.c (+4/-3)
src/indicator-session.c (+5/-11)
To merge this branch: bzr merge lp:~charlesk/indicator-session/lp-957342
Reviewer Review Type Date Requested Status
Conor Curran (community) 2012-03-16 Approve on 2012-03-19
Review via email: mp+97965@code.launchpad.net
To post a comment you must log in.
250. By Charles Kerr on 2012-03-16

plug two more memory leaks. g_variant_get("s") makes a newly-allocated duplicated string, g_variant_get("&s") returns the internal const string.

251. By Charles Kerr on 2012-03-17

fix memory leak updating the username label -- gtk_label_set_text() takes a const char*, we don't need to g_strdup() the string before passing it in

Conor Curran (cjcurran) wrote :

Well spotted !

Conor Curran (cjcurran) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/device-menu-mgr.c'
2--- src/device-menu-mgr.c 2012-02-23 14:40:17 +0000
3+++ src/device-menu-mgr.c 2012-03-17 00:26:18 +0000
4@@ -166,11 +166,12 @@
5 }
6
7 if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) {
8- g_debug("Keybinding changed to: %s", g_settings_get_string(settings, key));
9+ gchar * val = g_settings_get_string(settings, key);
10+ g_debug("Keybinding changed to: %s", val);
11 if (lock_menuitem != NULL) {
12- dbusmenu_menuitem_property_set_shortcut_string (lock_menuitem,
13- g_settings_get_string(settings, key));
14+ dbusmenu_menuitem_property_set_shortcut_string (lock_menuitem, val);
15 }
16+ g_free (val);
17 }
18 return;
19 }
20
21=== modified file 'src/indicator-session.c'
22--- src/indicator-session.c 2012-02-23 05:22:14 +0000
23+++ src/indicator-session.c 2012-03-17 00:26:18 +0000
24@@ -428,7 +428,7 @@
25 }
26
27 const gchar* username = NULL;
28- g_variant_get (result, "(s)", &username);
29+ g_variant_get (result, "(&s)", &username);
30 indicator_session_update_users_label (self, username);
31 return;
32 }
33@@ -481,7 +481,7 @@
34
35 if (g_strcmp0(signal_name, "UserRealNameUpdated") == 0) {
36 const gchar* username = NULL;
37- g_variant_get (parameters, "(s)", &username);
38+ g_variant_get (parameters, "(&s)", &username);
39 indicator_session_update_users_label (self, username);
40 }
41 else if (g_strcmp0(signal_name, "UserMenuIsVisible") == 0) {
42@@ -713,14 +713,8 @@
43 }
44
45 GSettings* settings = g_settings_new ("com.canonical.indicator.session");
46- gboolean use_name = g_settings_get_boolean (settings,
47- "show-real-name-on-panel");
48+ const gboolean use_name = g_settings_get_boolean (settings, "show-real-name-on-panel");
49+ gtk_label_set_text (self->users.label, name);
50+ gtk_widget_set_visible (GTK_WIDGET(self->users.label), use_name);
51 g_object_unref (settings);
52- gtk_label_set_text (self->users.label, g_strdup(name));
53- if (use_name){
54- gtk_widget_show(GTK_WIDGET(self->users.label));
55- }
56- else{
57- gtk_widget_hide(GTK_WIDGET(self->users.label));
58- }
59 }

Subscribers

People subscribed via source and target branches