From 9f415b383d35dd83c32edd9effd1878f8256cb62 Mon Sep 17 00:00:00 2001 From: Alexander Kojevnikov Date: Sun, 18 Mar 2012 17:37:52 +0800 Subject: [PATCH] Don't try to save if couldn't create the config dir Fixes a crash on OSX if the user doesn't own ~/.config --- src/spek-preferences.vala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/spek-preferences.vala b/src/spek-preferences.vala index 384f67d..ad8e62a 100644 --- a/src/spek-preferences.vala +++ b/src/spek-preferences.vala @@ -20,10 +20,13 @@ namespace Spek { public class Preferences { private KeyFile key_file; private string file_name; + private bool can_save = true; private Preferences () { file_name = Path.build_filename (Environment.get_user_config_dir (), "spek"); - DirUtils.create_with_parents (file_name, 0755); + if (DirUtils.create_with_parents (file_name, 0755) != 0) { + this.can_save = false; + } file_name = Path.build_filename (file_name, "preferences"); this.key_file = new KeyFile (); try { @@ -48,6 +51,9 @@ namespace Spek { } public void save () { + if (!can_save) { + return; + } var output = FileStream.open (file_name, "w+"); if (output != null) { output.puts (key_file.to_data ());