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 "layLayerTreeModel.h"
|
||||||
#include "dbLibraryManager.h"
|
#include "dbLibraryManager.h"
|
||||||
#include "dbLibrary.h"
|
#include "dbLibrary.h"
|
||||||
|
#include "tlLog.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
|
@ -89,6 +90,9 @@ RecentConfigurationPage::get_stored_values () const
|
||||||
std::string serialized_list = dispatcher ()->config_get (m_recent_cfg_name);
|
std::string serialized_list = dispatcher ()->config_get (m_recent_cfg_name);
|
||||||
|
|
||||||
std::list<std::vector<std::string> > values;
|
std::list<std::vector<std::string> > values;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
tl::Extractor ex (serialized_list.c_str ());
|
tl::Extractor ex (serialized_list.c_str ());
|
||||||
while (! ex.at_end ()) {
|
while (! ex.at_end ()) {
|
||||||
|
|
||||||
|
|
@ -101,6 +105,11 @@ RecentConfigurationPage::get_stored_values () const
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (tl::Exception &ex) {
|
||||||
|
tl::error << tl::to_string (tr ("Error reading configuration item ")) << m_recent_cfg_name << ": " << ex.msg ();
|
||||||
|
values.clear ();
|
||||||
|
}
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,7 +167,11 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
|
||||||
case RecentConfigurationPage::Bool:
|
case RecentConfigurationPage::Bool:
|
||||||
{
|
{
|
||||||
bool f = false;
|
bool f = false;
|
||||||
|
try {
|
||||||
tl::from_string (values [column], f);
|
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");
|
static QString checkmark = QString::fromUtf8 ("\xe2\x9c\x93");
|
||||||
item->setText (column, f ? checkmark : QString ()); // "checkmark"
|
item->setText (column, f ? checkmark : QString ()); // "checkmark"
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +180,12 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
|
||||||
case RecentConfigurationPage::Layer:
|
case RecentConfigurationPage::Layer:
|
||||||
{
|
{
|
||||||
int icon_size = mp_view->style ()->pixelMetric (QStyle::PM_ButtonIconSize);
|
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 ()) {
|
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->setIcon (column, lay::LayerTreeModel::icon_for_layer (l, mp_view, icon_size, icon_size, 0, true));
|
||||||
item->setText (column, tl::to_qstring (values [column]));
|
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;
|
int flag_column = 0;
|
||||||
for (std::list<ConfigurationDescriptor>::const_iterator c = m_cfg.begin (); c != m_cfg.end (); ++c, ++flag_column) {
|
for (std::list<ConfigurationDescriptor>::const_iterator c = m_cfg.begin (); c != m_cfg.end (); ++c, ++flag_column) {
|
||||||
if (c->rendering == RecentConfigurationPage::ArrayFlag) {
|
if (c->rendering == RecentConfigurationPage::ArrayFlag) {
|
||||||
|
try {
|
||||||
tl::from_string (values [flag_column], is_array);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -254,7 +276,11 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
|
||||||
case RecentConfigurationPage::PCellParameters:
|
case RecentConfigurationPage::PCellParameters:
|
||||||
{
|
{
|
||||||
std::map<std::string, tl::Variant> pcp;
|
std::map<std::string, tl::Variant> pcp;
|
||||||
|
try {
|
||||||
pcp = pcell_parameters_from_string (values [column]);
|
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;
|
std::string r;
|
||||||
for (std::map<std::string, tl::Variant>::const_iterator p = pcp.begin (); p != pcp.end (); ++p) {
|
for (std::map<std::string, tl::Variant>::const_iterator p = pcp.begin (); p != pcp.end (); ++p) {
|
||||||
if (p != pcp.begin ()) {
|
if (p != pcp.begin ()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue