[Xfce4-commits] <midori:master> Handle missing speedial.json and missing shortcuts array
Christian Dywan
noreply at xfce.org
Fri May 20 22:00:01 CEST 2011
Updating branch refs/heads/master
to 7f549b89a9e9939a7888d9e4ede628ef9c80df80 (commit)
from ad229121f0455455c5c24453d3bbfcc356eb08a6 (commit)
commit 7f549b89a9e9939a7888d9e4ede628ef9c80df80
Author: Christian Dywan <christian at twotoasts.de>
Date: Fri May 20 21:58:35 2011 +0200
Handle missing speedial.json and missing shortcuts array
midori/main.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/midori/main.c b/midori/main.c
index 007b03f..c6b8568 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -1605,7 +1605,12 @@ speeddial_new_from_file (const gchar* config,
}
katze_assign (config_file, g_build_filename (config, "speeddial.json", NULL));
- g_file_get_contents (config_file, &json_content, &json_length, NULL);
+ if (!g_file_get_contents (config_file, &json_content, &json_length, NULL))
+ {
+ katze_assign (json_content, g_strdup ("'{}'"));
+ json_length = strlen ("'{}'");
+ }
+
script = g_string_sized_new (json_length);
g_string_append (script, "var json = JSON.parse (");
g_string_append_len (script, json_content, json_length);
@@ -1619,7 +1624,7 @@ speeddial_new_from_file (const gchar* config,
" + 'title=' + tile['title'] + '\\n\\n';"
"} "
"var columns = json['width'] ? json['width'] : 3;"
- "var rows = json['shortcuts'].length / columns;"
+ "var rows = json['shortcuts'] ? json['shortcuts'].length / columns : 0;"
"keyfile += '[settings]\\n'"
" + 'columns=' + columns + '\\n'"
" + 'rows=' + (rows > 3 ? rows : 3) + '\\n\\n';"
More information about the Xfce4-commits
mailing list