Merge lp:~muktupavels/compiz/gwd-settings-storage-fix-memory-leaks into lp:compiz/0.9.12

Proposed by Alberts Muktupāvels
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 4015
Merged at revision: 4019
Proposed branch: lp:~muktupavels/compiz/gwd-settings-storage-fix-memory-leaks
Merge into: lp:compiz/0.9.12
Prerequisite: lp:~muktupavels/compiz/gwd-remove-settings-storage-interface
Diff against target: 180 lines (+49/-47)
1 file modified
gtk/window-decorator/gwd-settings-storage.c (+49/-47)
To merge this branch: bzr merge lp:~muktupavels/compiz/gwd-settings-storage-fix-memory-leaks
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Sam Spilsbury Approve
Review via email: mp+294505@code.launchpad.net

Commit message

Fix memory leaks in GWDSettingsStorage.

Description of the change

Fix memory leaks in GWDSettingsStorage.

To post a comment you must log in.
Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

Fix memory leaks in GWDSettingsStorage.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Looks fine to me - I'm not sure how I overlooked the fact that g_settings_get_string returns a copy when I first wrote this.

The only suggestion I would have is that translate_dashes_to_underscores should probably not return a value if it is modifying its argument.

review: Approve
4015. By Alberts Muktupāvels

Change translate_dashes_to_underscores function to not return value.

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

Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gtk/window-decorator/gwd-settings-storage.c'
2--- gtk/window-decorator/gwd-settings-storage.c 2016-05-12 13:50:40 +0000
3+++ gtk/window-decorator/gwd-settings-storage.c 2016-05-12 13:50:40 +0000
4@@ -100,21 +100,15 @@
5 return settings;
6 }
7
8-static inline gchar *
9-translate_dashes_to_underscores (const gchar *original)
10+static void
11+translate_dashes_to_underscores (gchar *original)
12 {
13 gint i = 0;
14- gchar *copy = g_strdup (original);
15-
16- if (!copy)
17- return NULL;
18-
19- for (; i < strlen (copy); ++i) {
20- if (copy[i] == '-')
21- copy[i] = '_';
22+
23+ for (i = 0; i < strlen (original); ++i) {
24+ if (original[i] == '-')
25+ original[i] = '_';
26 }
27-
28- return copy;
29 }
30
31 static void
32@@ -348,13 +342,16 @@
33 gwd_settings_storage_update_blur (GWDSettingsStorage *storage)
34 {
35 gchar *blur_type;
36+ gboolean retval;
37
38 if (!storage->gwd)
39 return FALSE;
40
41 blur_type = g_settings_get_string (storage->gwd, ORG_COMPIZ_GWD_KEY_BLUR_TYPE);
42+ retval = gwd_settings_writable_blur_changed (storage->writable, blur_type);
43+ g_free (blur_type);
44
45- return gwd_settings_writable_blur_changed (storage->writable, blur_type);
46+ return retval;
47 }
48
49 gboolean
50@@ -362,6 +359,7 @@
51 {
52 gboolean use_metacity_theme;
53 gchar *theme;
54+ gboolean retval;
55
56 if (!storage->gwd)
57 return FALSE;
58@@ -375,9 +373,10 @@
59 else
60 return FALSE;
61
62- return gwd_settings_writable_metacity_theme_changed (storage->writable,
63- use_metacity_theme,
64- theme);
65+ retval = gwd_settings_writable_metacity_theme_changed (storage->writable, use_metacity_theme, theme);
66+ g_free (theme);
67+
68+ return retval;
69 }
70
71 gboolean
72@@ -404,6 +403,7 @@
73 gwd_settings_storage_update_button_layout (GWDSettingsStorage *storage)
74 {
75 gchar *button_layout;
76+ gboolean retval;
77
78 if (storage->is_mate_desktop)
79 button_layout = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_BUTTON_LAYOUT);
80@@ -412,7 +412,10 @@
81 else
82 return FALSE;
83
84- return gwd_settings_writable_button_layout_changed (storage->writable, button_layout);
85+ retval = gwd_settings_writable_button_layout_changed (storage->writable, button_layout);
86+ g_free (button_layout);
87+
88+ return retval;
89 }
90
91 gboolean
92@@ -420,6 +423,7 @@
93 {
94 gchar *titlebar_font;
95 gboolean titlebar_system_font;
96+ gboolean retval;
97
98 if (storage->is_mate_desktop) {
99 titlebar_font = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT);
100@@ -430,9 +434,10 @@
101 } else
102 return FALSE;
103
104- return gwd_settings_writable_font_changed (storage->writable,
105- titlebar_system_font,
106- titlebar_font);
107+ retval = gwd_settings_writable_font_changed (storage->writable, titlebar_system_font, titlebar_font);
108+ g_free (titlebar_font);
109+
110+ return retval;
111 }
112
113 gboolean
114@@ -441,42 +446,39 @@
115 gchar *double_click_action;
116 gchar *middle_click_action;
117 gchar *right_click_action;
118+ gchar *mouse_wheel_action;
119+ gboolean retval;
120
121 if (!storage->gwd)
122 return FALSE;
123
124 if (storage->is_mate_desktop) {
125- double_click_action = translate_dashes_to_underscores (g_settings_get_string (storage->marco,
126- ORG_MATE_MARCO_GENERAL_ACTION_DOUBLE_CLICK_TITLEBAR));
127- middle_click_action = translate_dashes_to_underscores (g_settings_get_string (storage->marco,
128- ORG_MATE_MARCO_GENERAL_ACTION_MIDDLE_CLICK_TITLEBAR));
129- right_click_action = translate_dashes_to_underscores (g_settings_get_string (storage->marco,
130- ORG_MATE_MARCO_GENERAL_ACTION_RIGHT_CLICK_TITLEBAR));
131+ double_click_action = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_ACTION_DOUBLE_CLICK_TITLEBAR);
132+ middle_click_action = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_ACTION_MIDDLE_CLICK_TITLEBAR);
133+ right_click_action = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_ACTION_RIGHT_CLICK_TITLEBAR);
134 } else if (storage->desktop) {
135- double_click_action = translate_dashes_to_underscores (g_settings_get_string (storage->desktop,
136- ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR));
137- middle_click_action = translate_dashes_to_underscores (g_settings_get_string (storage->desktop,
138- ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR));
139- right_click_action = translate_dashes_to_underscores (g_settings_get_string (storage->desktop,
140- ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_RIGHT_CLICK_TITLEBAR));
141+ double_click_action = g_settings_get_string (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR);
142+ middle_click_action = g_settings_get_string (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR);
143+ right_click_action = g_settings_get_string (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_RIGHT_CLICK_TITLEBAR);
144 } else
145 return FALSE;
146
147- return gwd_settings_writable_titlebar_actions_changed (storage->writable,
148- double_click_action,
149- middle_click_action,
150- right_click_action,
151- g_settings_get_string (storage->gwd,
152- ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION));
153-
154- if (double_click_action)
155- g_free (double_click_action);
156-
157- if (middle_click_action)
158- g_free (middle_click_action);
159-
160- if (right_click_action)
161- g_free (right_click_action);
162+ translate_dashes_to_underscores (double_click_action);
163+ translate_dashes_to_underscores (middle_click_action);
164+ translate_dashes_to_underscores (right_click_action);
165+
166+ mouse_wheel_action = g_settings_get_string (storage->gwd, ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION);
167+
168+ retval = gwd_settings_writable_titlebar_actions_changed (storage->writable, double_click_action,
169+ middle_click_action, right_click_action,
170+ mouse_wheel_action);
171+
172+ g_free (double_click_action);
173+ g_free (middle_click_action);
174+ g_free (right_click_action);
175+ g_free (mouse_wheel_action);
176+
177+ return retval;
178 }
179
180 GSettings *

Subscribers

People subscribed via source and target branches