From 3aba98dade85a3c6131a9521100da7798dc0df93 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sat, 15 May 2010 16:00:09 +0200 Subject: [PATCH] Don't override the default profile when deleting that profile, and don't explode if a profile goes away --- terminatorlib/config.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index e2da23e2..2b013302 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -259,10 +259,16 @@ class Config(object): def del_profile(self, profile): """Delete a profile""" if profile == self.profile: + # FIXME: We should solve this problem by updating terminals when we + # remove a profile err('Config::del_profile: Deleting in-use profile %s.' % profile) self.set_profile('default') if self.base.profiles.has_key(profile): del(self.base.profiles[profile]) + options = self.options_get() + if options and options.profile == profile: + options.profile = None + self.options_set(options) def rename_profile(self, profile, newname): """Rename a profile""" @@ -600,6 +606,10 @@ class ConfigBase(Borg): def get_item(self, key, profile='default', plugin=None): """Look up a configuration item""" + if not self.profiles.has_key(profile): + # Hitting this generally implies a bug + profile = 'default' + if self.global_config.has_key(key): dbg('ConfigBase::get_item: %s found in globals: %s' % (key, self.global_config[key]))