Skip to content

Commit

Permalink
Fixed #102 (Potential issue while upgrading from .25.1 to .25.2)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
klayoutmatthias committed Mar 20, 2018
1 parent 19f25cc commit 21e2af2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/lay/lay/layMacroEditorDialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -3475,7 +3477,7 @@ class MacroEditorPluginDeclaration
options.push_back (std::pair<std::string, std::string> (cfg_macro_editor_save_all_on_run, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_macro_editor_debugging_enabled, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_macro_editor_file_watcher_enabled, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_macro_editor_font_size, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_macro_editor_font_size, ""));
options.push_back (std::pair<std::string, std::string> (cfg_macro_editor_font_family, ""));
options.push_back (std::pair<std::string, std::string> (cfg_macro_editor_stop_on_exception, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_macro_editor_tab_width, "8"));
Expand Down
20 changes: 15 additions & 5 deletions src/laybasic/laybasic/layPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "tlException.h"
#include "tlAssert.h"
#include "tlXMLParser.h"
#include "tlLog.h"

#include "layPlugin.h"
#include "tlExceptions.h"
Expand All @@ -37,6 +38,7 @@
#include <iostream>
#include <fstream>
#include <memory>
#include <QObject>

namespace lay
{
Expand Down Expand Up @@ -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<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
if ((const_cast<lay::PluginDeclaration *> (&*cls))->configure (name, value)) {
return;
try {
if ((const_cast<lay::PluginDeclaration *> (&*cls))->configure (name, value)) {
return;
}
} catch (tl::Exception &ex) {
tl::error << tl::to_string (QObject::tr ("Error on configure")) << " " << name << "='" << value << "': " << ex.msg ();
}
}
}
Expand Down Expand Up @@ -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!)
Expand Down

0 comments on commit 21e2af2

Please sign in to comment.