commit 9f415b383d35dd83c32edd9effd1878f8256cb62
parent 63dc489bd4df4490a80f61f65ed6f2c2ae68642a
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date: Sun, 18 Mar 2012 17:37:52 +0800
Don't try to save if couldn't create the config dir
Fixes a crash on OSX if the user doesn't own ~/.config
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git 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 ());