diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-07-14 21:20:50 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-07-14 21:20:50 +0100 |
| commit | 267e5cd9a9cd85c90fe80bdf14fead3923fd5489 (patch) | |
| tree | 0a69f0657a57eac6870a747e1e3fa22315e3050c /src/lib/config.cc | |
| parent | e693014c1cf9a5204d54d753640be6bd4f00b195 (diff) | |
Better behaviour if config fails to load.
Create a default config if any exception is thrown by ::read, and
tell the UI so that it can pop up a message to say what has happened.
Diffstat (limited to 'src/lib/config.cc')
| -rw-r--r-- | src/lib/config.cc | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index c483734f8..c6c6cac8b 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -59,6 +59,7 @@ using boost::optional; using boost::algorithm::trim; Config* Config::_instance = 0; +boost::signals2::signal<void ()> Config::FailedToLoad; /** Construct default configuration */ Config::Config () @@ -143,16 +144,8 @@ Config::create_certificate_chain () void Config::read () +try { - if (!have_existing ("config.xml")) { - /* Make a new set of signing certificates and key */ - _signer_chain = create_certificate_chain (); - /* And similar for decryption of KDMs */ - _decryption_chain = create_certificate_chain (); - write (); - return; - } - cxml::Document f ("Config"); f.read_file (path ("config.xml")); optional<string> c; @@ -305,6 +298,19 @@ Config::read () read_cinemas (f); } } +catch (...) { + if (have_existing ("config.xml")) { + /* We have a config file but it didn't load */ + FailedToLoad (); + } + set_defaults (); + /* Make a new set of signing certificates and key */ + _signer_chain = create_certificate_chain (); + /* And similar for decryption of KDMs */ + _decryption_chain = create_certificate_chain (); + write (); +} + /** @return Filename to write configuration to */ boost::filesystem::path |
