From 21e2af2a976ac5d3df68f7f4f591ecf04b2882a9 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 20 Mar 2018 18:52:00 +0100 Subject: [PATCH] Fixed #102 (Potential issue while upgrading from .25.1 to .25.2) The reason was that for 0.25.1 "macro-editor-font-size" was allowed to be an empty string (the default). Which meant: take default application font size. In 0.25.2 this now was required to be a number and 0 was the default for "auto" font size. Two changes: - The default is back to empty string ("0" is still allowed as default) - The application was made safe against broken configuration files: an error is printed to the log, but apart from that the application will work (the configuration value is ignored however). --- src/lay/lay/layMacroEditorDialog.cc | 6 ++++-- src/laybasic/laybasic/layPlugin.cc | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/lay/lay/layMacroEditorDialog.cc b/src/lay/lay/layMacroEditorDialog.cc index 897a996cdd..688990ee15 100644 --- a/src/lay/lay/layMacroEditorDialog.cc +++ b/src/lay/lay/layMacroEditorDialog.cc @@ -786,7 +786,9 @@ MacroEditorDialog::configure (const std::string &name, const std::string &value) } else if (name == cfg_macro_editor_font_size) { int v = m_font_size; - tl::from_string (value, v); + if (! value.empty ()) { + tl::from_string (value, v); + } if (v != m_font_size) { m_font_size = v; m_needs_update = true; @@ -3475,7 +3477,7 @@ class MacroEditorPluginDeclaration options.push_back (std::pair (cfg_macro_editor_save_all_on_run, "false")); options.push_back (std::pair (cfg_macro_editor_debugging_enabled, "true")); options.push_back (std::pair (cfg_macro_editor_file_watcher_enabled, "true")); - options.push_back (std::pair (cfg_macro_editor_font_size, "0")); + options.push_back (std::pair (cfg_macro_editor_font_size, "")); options.push_back (std::pair (cfg_macro_editor_font_family, "")); options.push_back (std::pair (cfg_macro_editor_stop_on_exception, "true")); options.push_back (std::pair (cfg_macro_editor_tab_width, "8")); diff --git a/src/laybasic/laybasic/layPlugin.cc b/src/laybasic/laybasic/layPlugin.cc index 38f0b8b6f0..f59f597e7b 100644 --- a/src/laybasic/laybasic/layPlugin.cc +++ b/src/laybasic/laybasic/layPlugin.cc @@ -27,6 +27,7 @@ #include "tlException.h" #include "tlAssert.h" #include "tlXMLParser.h" +#include "tlLog.h" #include "layPlugin.h" #include "tlExceptions.h" @@ -37,6 +38,7 @@ #include #include #include +#include namespace lay { @@ -293,8 +295,12 @@ Plugin::config_set (const std::string &name, const std::string &value) // look for plugins that receive that configuration statically if the root is addressed if (! mp_parent && ! m_standalone) { for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - if ((const_cast (&*cls))->configure (name, value)) { - return; + try { + if ((const_cast (&*cls))->configure (name, value)) { + return; + } + } catch (tl::Exception &ex) { + tl::error << tl::to_string (QObject::tr ("Error on configure")) << " " << name << "='" << value << "': " << ex.msg (); } } } @@ -381,9 +387,13 @@ Plugin::do_config_end () bool Plugin::do_config_set (const std::string &name, const std::string &value) { - if (configure (name, value)) { - // taken by us - don't propagate to the children - return true; + try { + if (configure (name, value)) { + // taken by us - don't propagate to the children + return true; + } + } catch (tl::Exception &ex) { + tl::error << tl::to_string (QObject::tr ("Error on configure")) << " " << name << "='" << value << "': " << ex.msg (); } // propagate to all children (not only the first that takes it!)