mirror of https://github.com/KLayout/klayout.git
More robustness against configuration corruption.
This commit is contained in:
parent
4b8577a89b
commit
4213f44d72
|
|
@ -27,6 +27,7 @@
|
|||
#include "layLayerTreeModel.h"
|
||||
#include "dbLibraryManager.h"
|
||||
#include "dbLibrary.h"
|
||||
#include "tlLog.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHeaderView>
|
||||
|
|
@ -89,16 +90,24 @@ RecentConfigurationPage::get_stored_values () const
|
|||
std::string serialized_list = dispatcher ()->config_get (m_recent_cfg_name);
|
||||
|
||||
std::list<std::vector<std::string> > values;
|
||||
tl::Extractor ex (serialized_list.c_str ());
|
||||
while (! ex.at_end ()) {
|
||||
|
||||
values.push_back (std::vector<std::string> ());
|
||||
while (! ex.at_end () && ! ex.test (";")) {
|
||||
values.back ().push_back (std::string ());
|
||||
ex.read_word_or_quoted (values.back ().back ());
|
||||
ex.test (",");
|
||||
try {
|
||||
|
||||
tl::Extractor ex (serialized_list.c_str ());
|
||||
while (! ex.at_end ()) {
|
||||
|
||||
values.push_back (std::vector<std::string> ());
|
||||
while (! ex.at_end () && ! ex.test (";")) {
|
||||
values.back ().push_back (std::string ());
|
||||
ex.read_word_or_quoted (values.back ().back ());
|
||||
ex.test (",");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (tl::Exception &ex) {
|
||||
tl::error << tl::to_string (tr ("Error reading configuration item ")) << m_recent_cfg_name << ": " << ex.msg ();
|
||||
values.clear ();
|
||||
}
|
||||
|
||||
return values;
|
||||
|
|
@ -158,7 +167,11 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
|
|||
case RecentConfigurationPage::Bool:
|
||||
{
|
||||
bool f = false;
|
||||
tl::from_string (values [column], f);
|
||||
try {
|
||||
tl::from_string (values [column], f);
|
||||
} catch (tl::Exception &ex) {
|
||||
tl::error << tl::to_string (tr ("Configuration error (ArrayFlag/Bool): ")) << ex.msg ();
|
||||
}
|
||||
static QString checkmark = QString::fromUtf8 ("\xe2\x9c\x93");
|
||||
item->setText (column, f ? checkmark : QString ()); // "checkmark"
|
||||
}
|
||||
|
|
@ -167,7 +180,12 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
|
|||
case RecentConfigurationPage::Layer:
|
||||
{
|
||||
int icon_size = mp_view->style ()->pixelMetric (QStyle::PM_ButtonIconSize);
|
||||
lay::LayerPropertiesConstIterator l = lp_iter_from_string (mp_view, values [column]);
|
||||
lay::LayerPropertiesConstIterator l;
|
||||
try {
|
||||
l = lp_iter_from_string (mp_view, values [column]);
|
||||
} catch (tl::Exception &ex) {
|
||||
tl::error << tl::to_string (tr ("Configuration error (Layer): ")) << ex.msg ();
|
||||
}
|
||||
if (! l.is_null () && ! l.at_end ()) {
|
||||
item->setIcon (column, lay::LayerTreeModel::icon_for_layer (l, mp_view, icon_size, icon_size, 0, true));
|
||||
item->setText (column, tl::to_qstring (values [column]));
|
||||
|
|
@ -199,7 +217,11 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
|
|||
int flag_column = 0;
|
||||
for (std::list<ConfigurationDescriptor>::const_iterator c = m_cfg.begin (); c != m_cfg.end (); ++c, ++flag_column) {
|
||||
if (c->rendering == RecentConfigurationPage::ArrayFlag) {
|
||||
tl::from_string (values [flag_column], is_array);
|
||||
try {
|
||||
tl::from_string (values [flag_column], is_array);
|
||||
} catch (tl::Exception &ex) {
|
||||
tl::error << tl::to_string (tr ("Configuration error (IntIfArray/DoubleIfArray): ")) << ex.msg ();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -254,7 +276,11 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
|
|||
case RecentConfigurationPage::PCellParameters:
|
||||
{
|
||||
std::map<std::string, tl::Variant> pcp;
|
||||
pcp = pcell_parameters_from_string (values [column]);
|
||||
try {
|
||||
pcp = pcell_parameters_from_string (values [column]);
|
||||
} catch (tl::Exception &ex) {
|
||||
tl::error << tl::to_string (tr ("Configuration error (PCellParameters): ")) << ex.msg ();
|
||||
}
|
||||
std::string r;
|
||||
for (std::map<std::string, tl::Variant>::const_iterator p = pcp.begin (); p != pcp.end (); ++p) {
|
||||
if (p != pcp.begin ()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue