mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-22 14:07:15 +02:00
Some enhancements to package manager
- So not update macros while installing: avoids transient error messages - Offer to autorun macros also after package update (so far only on package new installation)
This commit is contained in:
@@ -385,9 +385,9 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// determine the paths currently in use
|
// determine the paths currently in use
|
||||||
std::map<std::string, const ExternalPathDescriptor *> prev_folders_by_path;
|
std::map<std::string, ExternalPathDescriptor> prev_folders_by_path;
|
||||||
for (std::vector<ExternalPathDescriptor>::const_iterator p = m_external_paths.begin (); p != m_external_paths.end (); ++p) {
|
for (std::vector<ExternalPathDescriptor>::const_iterator p = m_external_paths.begin (); p != m_external_paths.end (); ++p) {
|
||||||
prev_folders_by_path.insert (std::make_pair (p->path, p.operator-> ()));
|
prev_folders_by_path.insert (std::make_pair (p->path, *p));
|
||||||
}
|
}
|
||||||
|
|
||||||
// gets the external paths (tech, packages) into m_external_paths
|
// gets the external paths (tech, packages) into m_external_paths
|
||||||
@@ -433,23 +433,39 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
|
|||||||
|
|
||||||
for (std::vector<ExternalPathDescriptor>::const_iterator p = m_external_paths.begin (); p != m_external_paths.end (); ++p) {
|
for (std::vector<ExternalPathDescriptor>::const_iterator p = m_external_paths.begin (); p != m_external_paths.end (); ++p) {
|
||||||
|
|
||||||
if (prev_folders_by_path.find (p->path) != prev_folders_by_path.end ()) {
|
auto pf = prev_folders_by_path.find (p->path);
|
||||||
continue;
|
if (pf != prev_folders_by_path.end ()) {
|
||||||
}
|
|
||||||
|
|
||||||
if (tl::verbosity () >= 20) {
|
if (pf->second.version != p->version) {
|
||||||
tl::info << "Adding macro folder " << p->path << ", category '" << p->cat << "' for '" << p->description << "'";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the folder. Note: it may happen that a macro folder for the tech specific macros already exists in
|
if (tl::verbosity () >= 20) {
|
||||||
// a non-tech context.
|
tl::info << "New version (" << p->version << " vs. " << pf->second.version << ") of macro folder " << p->path << ", category '" << p->cat << "' for '" << p->description << "'";
|
||||||
// In that case, the add_folder method will return 0.
|
}
|
||||||
|
|
||||||
|
lym::MacroCollection *mc = lym::MacroCollection::root ().folder_by_name (p->path);
|
||||||
|
if (mc) {
|
||||||
|
new_folders.push_back (mc);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (tl::verbosity () >= 20) {
|
||||||
|
tl::info << "Adding macro folder " << p->path << ", category '" << p->cat << "' for '" << p->description << "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the folder. Note: it may happen that a macro folder for the tech specific macros already exists in
|
||||||
|
// a non-tech context.
|
||||||
|
// In that case, the add_folder method will return 0.
|
||||||
|
|
||||||
|
// TODO: is it wise to make this writeable?
|
||||||
|
lym::MacroCollection *mc = lym::MacroCollection::root ().add_folder (p->description, p->path, p->cat, p->readonly);
|
||||||
|
if (mc) {
|
||||||
|
mc->set_virtual_mode (p->type);
|
||||||
|
new_folders.push_back (mc);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: is it wise to make this writeable?
|
|
||||||
lym::MacroCollection *mc = lym::MacroCollection::root ().add_folder (p->description, p->path, p->cat, p->readonly);
|
|
||||||
if (mc) {
|
|
||||||
mc->set_virtual_mode (p->type);
|
|
||||||
new_folders.push_back (mc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -565,7 +581,7 @@ MacroController::sync_macro_sources ()
|
|||||||
if (*f != macro_categories () [c].name) {
|
if (*f != macro_categories () [c].name) {
|
||||||
description += " - " + tl::to_string (tr ("%1 branch").arg (tl::to_qstring (*f)));
|
description += " - " + tl::to_string (tr ("%1 branch").arg (tl::to_qstring (*f)));
|
||||||
}
|
}
|
||||||
external_paths.push_back (ExternalPathDescriptor (tl::to_string (macro_dir.path ()), description, macro_categories () [c].name, lym::MacroCollection::SaltFolder, g->is_readonly ()));
|
external_paths.push_back (ExternalPathDescriptor (tl::to_string (macro_dir.path ()), description, macro_categories () [c].name, lym::MacroCollection::SaltFolder, g->is_readonly (), g->version ()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,8 +204,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
struct ExternalPathDescriptor
|
struct ExternalPathDescriptor
|
||||||
{
|
{
|
||||||
ExternalPathDescriptor (const std::string &_path, const std::string &_description, const std::string &_cat, lym::MacroCollection::FolderType _type, bool _readonly)
|
ExternalPathDescriptor (const std::string &_path, const std::string &_description, const std::string &_cat, lym::MacroCollection::FolderType _type, bool _readonly, const std::string &_version = std::string ())
|
||||||
: path (_path), description (_description), cat (_cat), type (_type), readonly (_readonly)
|
: path (_path), description (_description), cat (_cat), type (_type), version (_version), readonly (_readonly)
|
||||||
{
|
{
|
||||||
// .. nothing yet ..
|
// .. nothing yet ..
|
||||||
}
|
}
|
||||||
@@ -214,6 +214,7 @@ private:
|
|||||||
std::string description;
|
std::string description;
|
||||||
std::string cat;
|
std::string cat;
|
||||||
lym::MacroCollection::FolderType type;
|
lym::MacroCollection::FolderType type;
|
||||||
|
std::string version;
|
||||||
bool readonly;
|
bool readonly;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "layConfig.h"
|
#include "layConfig.h"
|
||||||
#include "layMainWindow.h"
|
#include "layMainWindow.h"
|
||||||
#include "layQtTools.h"
|
#include "layQtTools.h"
|
||||||
|
#include "layBusy.h"
|
||||||
#include "tlLog.h"
|
#include "tlLog.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -138,11 +139,12 @@ SaltController::show_editor ()
|
|||||||
lay::restore_dialog_state (mp_salt_dialog, s);
|
lay::restore_dialog_state (mp_salt_dialog, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// while running the dialog, don't watch file events - that would interfere with
|
{
|
||||||
// the changes applied by the dialog itself.
|
// while running the dialog, don't watch file events - that would interfere with
|
||||||
m_file_watcher->enable (false);
|
// the changes applied by the dialog itself.
|
||||||
mp_salt_dialog->exec ();
|
lay::BusySection busy_section; // disable file watcher
|
||||||
m_file_watcher->enable (true);
|
mp_salt_dialog->exec ();
|
||||||
|
}
|
||||||
|
|
||||||
mp_plugin_root->config_set (cfg_salt_manager_window_state, lay::save_dialog_state (mp_salt_dialog));
|
mp_plugin_root->config_set (cfg_salt_manager_window_state, lay::save_dialog_state (mp_salt_dialog));
|
||||||
|
|
||||||
@@ -154,13 +156,13 @@ SaltController::show_editor ()
|
|||||||
void
|
void
|
||||||
SaltController::sync_file_watcher ()
|
SaltController::sync_file_watcher ()
|
||||||
{
|
{
|
||||||
|
lay::BusySection busy_section; // disable file watcher
|
||||||
|
|
||||||
if (m_file_watcher) {
|
if (m_file_watcher) {
|
||||||
m_file_watcher->clear ();
|
m_file_watcher->clear ();
|
||||||
m_file_watcher->enable (false);
|
|
||||||
for (lay::Salt::flat_iterator g = m_salt.begin_flat (); g != m_salt.end_flat (); ++g) {
|
for (lay::Salt::flat_iterator g = m_salt.begin_flat (); g != m_salt.end_flat (); ++g) {
|
||||||
m_file_watcher->add_file ((*g)->path ());
|
m_file_watcher->add_file ((*g)->path ());
|
||||||
}
|
}
|
||||||
m_file_watcher->enable (true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +218,18 @@ SaltController::install_packages (const std::vector<std::string> &packages, bool
|
|||||||
manager.compute_packages (m_salt, salt_mine);
|
manager.compute_packages (m_salt, salt_mine);
|
||||||
}
|
}
|
||||||
|
|
||||||
return manager.execute (0, m_salt);
|
bool result = false;
|
||||||
|
|
||||||
|
{
|
||||||
|
// while running the dialog, don't watch file events - that would interfere with
|
||||||
|
// the changes applied by the dialog itself.
|
||||||
|
lay::BusySection busy_section; // disable file watcher
|
||||||
|
result = manager.execute (0, m_salt);
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_file_watcher ();
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "layBusy.h"
|
#include "layBusy.h"
|
||||||
#include "tlThreads.h"
|
#include "tlThreads.h"
|
||||||
|
#include "tlFileSystemWatcher.h"
|
||||||
|
|
||||||
namespace lay
|
namespace lay
|
||||||
{
|
{
|
||||||
@@ -61,6 +62,9 @@ BusySection::BusySection ()
|
|||||||
m_previous_mode = mp_busy_mode->is_busy ();
|
m_previous_mode = mp_busy_mode->is_busy ();
|
||||||
mp_busy_mode->enter_busy_mode (true);
|
mp_busy_mode->enter_busy_mode (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disable file system watchers during busy periods
|
||||||
|
tl::FileSystemWatcher::global_enable (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
BusySection::~BusySection ()
|
BusySection::~BusySection ()
|
||||||
@@ -70,6 +74,8 @@ BusySection::~BusySection ()
|
|||||||
mp_busy_mode->enter_busy_mode (m_previous_mode);
|
mp_busy_mode->enter_busy_mode (m_previous_mode);
|
||||||
}
|
}
|
||||||
mp_busy_mode = 0;
|
mp_busy_mode = 0;
|
||||||
|
|
||||||
|
tl::FileSystemWatcher::global_enable (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
@@ -31,6 +31,9 @@
|
|||||||
namespace tl
|
namespace tl
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// The global enable counter (<0: disable)
|
||||||
|
static int s_global_enable = 0;
|
||||||
|
|
||||||
// The maximum allowed processing time in seconds
|
// The maximum allowed processing time in seconds
|
||||||
const double processing_time = 0.02;
|
const double processing_time = 0.02;
|
||||||
|
|
||||||
@@ -47,6 +50,16 @@ FileSystemWatcher::FileSystemWatcher (QObject *parent)
|
|||||||
m_batch_size = 1000;
|
m_batch_size = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FileSystemWatcher::global_enable (bool en)
|
||||||
|
{
|
||||||
|
if (en) {
|
||||||
|
++s_global_enable;
|
||||||
|
} else {
|
||||||
|
--s_global_enable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FileSystemWatcher::enable (bool en)
|
FileSystemWatcher::enable (bool en)
|
||||||
{
|
{
|
||||||
@@ -120,6 +133,10 @@ FileSystemWatcher::remove_file (const std::string &path)
|
|||||||
void
|
void
|
||||||
FileSystemWatcher::timeout ()
|
FileSystemWatcher::timeout ()
|
||||||
{
|
{
|
||||||
|
if (s_global_enable < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tl::Clock start = tl::Clock::current ();
|
tl::Clock start = tl::Clock::current ();
|
||||||
|
|
||||||
if (m_iter == m_files.end ()) {
|
if (m_iter == m_files.end ()) {
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
FileSystemWatcher (QObject *parent = 0);
|
FileSystemWatcher (QObject *parent = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Global enable/disable
|
||||||
|
*/
|
||||||
|
static void global_enable (bool en);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enables or disables the file watcher
|
* @brief Enables or disables the file watcher
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user