From: Christian Dywan Date: Fri, 20 May 2011 19:58:35 +0000 (+0200) Subject: Handle missing speedial.json and missing shortcuts array X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f549b89a9e9939a7888d9e4ede628ef9c80df80;p=midori Handle missing speedial.json and missing shortcuts array --- diff --git a/midori/main.c b/midori/main.c index 007b03f9..c6b8568f 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';"