mirror of https://github.com/KLayout/klayout.git
* Fixed #591 (crash on Macro/Add Location) The main reason was that the QSortFilterProxyModel is very sensitive to the order of signals it receives from the proxy model. In this case, dataChanged() must not be send between layoutAboutToBeChanged() and layoutChanged(). This happened implicitly during load() of a macro while scanning the freshly added folder. * Fixed another part of #591: ability to disable template selection pop-up in macro editor. Tied to the tip window now - if this is dismissed, no template selection dialog will be shown.
This commit is contained in:
parent
4db20b3b48
commit
6365ddfe82
|
|
@ -87,5 +87,6 @@ BD_PUBLIC int strmrun (int argc, char *argv[])
|
|||
|
||||
lym::Macro macro;
|
||||
macro.load_from (script);
|
||||
macro.set_file_path (script);
|
||||
return macro.run ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -668,18 +668,21 @@ BEGIN_PROTECTED
|
|||
}
|
||||
}
|
||||
|
||||
if (collection && (force_add || (collection->begin () == collection->end () && collection->begin_children () == collection->end_children ()))) {
|
||||
bool open_template_dialog = false;
|
||||
if (! force_add && collection && (collection->begin () == collection->end () && collection->begin_children () == collection->end_children ())) {
|
||||
TipDialog td (this,
|
||||
tl::to_string (QObject::tr ("<html><body>To get started with the macro development feature, read the documentation provided: <a href=\"int:/about/macro_editor.xml\">About Macro Development</a>.</body></html>")),
|
||||
"macro-editor-basic-tips");
|
||||
open_template_dialog = td.exec_dialog () && td.will_be_shown ();
|
||||
}
|
||||
|
||||
if (collection && (force_add || open_template_dialog)) {
|
||||
lym::Macro *m = new_macro ();
|
||||
if (force_add && m) {
|
||||
set_run_macro (m);
|
||||
}
|
||||
}
|
||||
|
||||
TipDialog td (this,
|
||||
tl::to_string (QObject::tr ("<html><body>To get started with the macro development feature, read the documentation provided: <a href=\"int:/about/macro_editor.xml\">About Macro Development</a>.</body></html>")),
|
||||
"macro-editor-basic-tips");
|
||||
td.exec_dialog ();
|
||||
|
||||
} else {
|
||||
|
||||
if (! cat.empty ()) {
|
||||
|
|
|
|||
|
|
@ -128,12 +128,9 @@ TipDialog::no_pressed ()
|
|||
accept ();
|
||||
}
|
||||
|
||||
bool
|
||||
TipDialog::do_exec_dialog (button_type *button)
|
||||
static std::pair<bool, int>
|
||||
tip_dialog_status (const std::string &key)
|
||||
{
|
||||
bool must_show = true;
|
||||
mp_res = button;
|
||||
|
||||
std::string th;
|
||||
if (lay::Dispatcher::instance ()) {
|
||||
lay::Dispatcher::instance ()->config_get (cfg_tip_window_hidden, th);
|
||||
|
|
@ -148,20 +145,39 @@ TipDialog::do_exec_dialog (button_type *button)
|
|||
}
|
||||
int r = -1;
|
||||
ex.test ("=") && ex.try_read (r);
|
||||
if (k == m_key) {
|
||||
if (r >= 0) {
|
||||
*mp_res = button_type (r);
|
||||
}
|
||||
must_show = false;
|
||||
break;
|
||||
if (k == key) {
|
||||
return std::make_pair (false, r);
|
||||
}
|
||||
ex.test (",");
|
||||
}
|
||||
|
||||
if (must_show) {
|
||||
return std::make_pair (true, -1);
|
||||
}
|
||||
|
||||
bool
|
||||
TipDialog::will_be_shown ()
|
||||
{
|
||||
return tip_dialog_status (m_key).first;
|
||||
}
|
||||
|
||||
bool
|
||||
TipDialog::do_exec_dialog (button_type *button)
|
||||
{
|
||||
mp_res = button;
|
||||
|
||||
std::string th;
|
||||
if (lay::Dispatcher::instance ()) {
|
||||
lay::Dispatcher::instance ()->config_get (cfg_tip_window_hidden, th);
|
||||
}
|
||||
|
||||
std::pair<bool, int> td_status = tip_dialog_status (m_key);
|
||||
if (td_status.first) {
|
||||
exec ();
|
||||
return true;
|
||||
} else {
|
||||
if (td_status.second >= 0) {
|
||||
*mp_res = button_type (td_status.second);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,11 @@ public:
|
|||
*/
|
||||
~TipDialog ();
|
||||
|
||||
/**
|
||||
* @brief Returns true, if the tip dialog will be shown
|
||||
*/
|
||||
bool will_be_shown ();
|
||||
|
||||
/**
|
||||
* @brief Show the dialog
|
||||
*
|
||||
|
|
|
|||
|
|
@ -251,6 +251,7 @@ void Macro::load_from (const std::string &fn)
|
|||
}
|
||||
|
||||
m_modified = true;
|
||||
m_is_file = true;
|
||||
on_changed ();
|
||||
}
|
||||
|
||||
|
|
@ -293,9 +294,6 @@ void Macro::load_from_string (const std::string &text, const std::string &url)
|
|||
void Macro::load ()
|
||||
{
|
||||
load_from (path ());
|
||||
m_modified = false;
|
||||
m_is_file = true;
|
||||
on_changed ();
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -449,13 +447,13 @@ void Macro::reset_modified ()
|
|||
|
||||
bool Macro::rename (const std::string &n)
|
||||
{
|
||||
if (m_is_file) {
|
||||
if (m_is_file && parent ()) {
|
||||
std::string suffix = suffix_for_format (m_interpreter, m_dsl_interpreter, m_format);
|
||||
if (tl::verbosity () >= 20) {
|
||||
tl::log << "Renaming macro " << path () << " to " << n;
|
||||
}
|
||||
QFile f (tl::to_qstring (path ()));
|
||||
if (! f.rename (QFileInfo (QDir (tl::to_qstring (mp_parent->path ())), tl::to_qstring (n + suffix)).filePath ())) {
|
||||
if (! f.rename (QFileInfo (QDir (tl::to_qstring (parent ()->path ())), tl::to_qstring (n + suffix)).filePath ())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1294,14 +1292,15 @@ MacroCollection::add_folder (const std::string &description, const std::string &
|
|||
begin_changes ();
|
||||
|
||||
MacroCollection *mc = m_folders.insert (std::make_pair (path, new MacroCollection ())).first->second;
|
||||
mc->set_parent (this);
|
||||
mc->set_name (path);
|
||||
mc->set_description (description);
|
||||
mc->set_category (cat);
|
||||
mc->set_readonly (readonly);
|
||||
mc->scan (path);
|
||||
mc->set_parent (this);
|
||||
|
||||
on_changed ();
|
||||
on_macro_changed (0);
|
||||
|
||||
return mc;
|
||||
}
|
||||
|
|
@ -1376,7 +1375,6 @@ void MacroCollection::scan (const std::string &path)
|
|||
}
|
||||
if (! found) {
|
||||
Macro *m = m_macros.insert (std::make_pair (n, new Macro ()))->second;
|
||||
m->set_parent (this);
|
||||
m->set_interpreter (interpreter);
|
||||
m->set_autorun_default (autorun);
|
||||
m->set_autorun (autorun);
|
||||
|
|
@ -1387,6 +1385,7 @@ void MacroCollection::scan (const std::string &path)
|
|||
m->set_readonly (m_readonly);
|
||||
m->reset_modified ();
|
||||
m->set_is_file ();
|
||||
m->set_parent (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1425,6 +1424,7 @@ void MacroCollection::scan (const std::string &path)
|
|||
try {
|
||||
|
||||
std::string n = tl::to_string (QFileInfo (*f).completeBaseName ());
|
||||
std::string mp = tl::to_string (dir.absoluteFilePath (*f));
|
||||
|
||||
Macro::Format format = Macro::NoFormat;
|
||||
Macro::Interpreter interpreter = Macro::None;
|
||||
|
|
@ -1451,10 +1451,11 @@ void MacroCollection::scan (const std::string &path)
|
|||
m->set_autorun (autorun);
|
||||
m->set_interpreter (interpreter);
|
||||
m->set_dsl_interpreter (dsl_name);
|
||||
m->set_parent (this);
|
||||
m->set_name (n);
|
||||
m->load ();
|
||||
m->load_from (mp);
|
||||
m->reset_modified ();
|
||||
m->set_readonly (m_readonly);
|
||||
m->set_parent (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1478,12 +1479,12 @@ void MacroCollection::scan (const std::string &path)
|
|||
MacroCollection *&mc = m_folders.insert (std::make_pair (n, (MacroCollection *) 0)).first->second;
|
||||
if (! mc) {
|
||||
mc = new MacroCollection ();
|
||||
mc->set_parent (this);
|
||||
mc->set_name (n);
|
||||
mc->set_virtual_mode (NotVirtual);
|
||||
bool ro = (m_readonly || ! QFileInfo (dir.filePath (*f)).isWritable ());
|
||||
mc->set_readonly (ro);
|
||||
mc->scan (tl::to_string (dir.filePath (*f)));
|
||||
mc->set_parent (this);
|
||||
}
|
||||
|
||||
} catch (tl::Exception &ex) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue