[gnac/devel] Fixed a memory leak
- From: Benoît Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/devel] Fixed a memory leak
- Date: Fri, 5 Nov 2010 13:16:55 +0000 (UTC)
commit 723eb508652a0ad749ce59e70804a4af2d24e441
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date: Fri Nov 5 13:16:38 2010 +0000
Fixed a memory leak
data/gnac.schemas.in | 2 +-
src/profiles/gnac-profiles-manager.c | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/data/gnac.schemas.in b/data/gnac.schemas.in
index 0a3fe08..2fa20d3 100644
--- a/data/gnac.schemas.in
+++ b/data/gnac.schemas.in
@@ -106,7 +106,7 @@
<applyto>/apps/gnac/conversion/last_used_profile</applyto>
<owner>gnac</owner>
<type>string</type>
- <default>false</default>
+ <default></default>
<locale name="C">
<short>Last used profile</short>
</locale>
diff --git a/src/profiles/gnac-profiles-manager.c b/src/profiles/gnac-profiles-manager.c
index 1f1b113..9f83e1f 100644
--- a/src/profiles/gnac-profiles-manager.c
+++ b/src/profiles/gnac-profiles-manager.c
@@ -256,6 +256,7 @@ gnac_profiles_mgr_list_profiles(void)
{
AudioProfileGeneric *profile;
const gchar *profile_file_name;
+ gchar *last_profile;
gchar *profile_file_full_path;
gchar *profile_file_path;
GError *error = NULL;
@@ -291,6 +292,8 @@ gnac_profiles_mgr_list_profiles(void)
g_print(_("Available audio profiles:"));
g_print("\n\n");
+ last_profile = gnac_gconf_get_string(GNAC_GCONF_LAST_USED_PROFILE);
+
guint count = 0;
while ((file_info = g_file_enumerator_next_file(files, NULL, NULL))) {
if (g_file_info_get_file_type(file_info) == G_FILE_TYPE_REGULAR) {
@@ -304,9 +307,11 @@ gnac_profiles_mgr_list_profiles(void)
if (profile) {
const gchar *name = (profile->generic)->name;
gchar *count_str = g_strdup_printf("%u", count);
- g_print("\t%2s) %s\n", g_str_equal(name,
- gnac_gconf_get_string(GNAC_GCONF_LAST_USED_PROFILE)) ?
- "*" : count_str, name);
+ /* if last_used_profile is not set, assume the
+ * first profile was last used */
+ g_print("\t%2s) %s\n", (((count == 0)
+ && (!last_profile || g_str_equal(last_profile, "")))
+ || g_str_equal(name, last_profile)) ? "*" : count_str, name);
count++;
g_free(count_str);
}
@@ -326,6 +331,7 @@ gnac_profiles_mgr_list_profiles(void)
g_print("\n");
/* Cleanup */
+ g_free(last_profile);
g_object_unref(dir);
g_file_enumerator_close(files, NULL, NULL);
g_object_unref(files);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]