diff --git a/src/lay/lay/laySaltController.cc b/src/lay/lay/laySaltController.cc index efd85a58e..51b53ae66 100644 --- a/src/lay/lay/laySaltController.cc +++ b/src/lay/lay/laySaltController.cc @@ -143,7 +143,7 @@ SaltController::show_editor () { // 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 + tl::FileSystemWatcherDisabled disable_file_watcher; // disable file watcher mp_salt_dialog->exec (); } @@ -157,7 +157,7 @@ SaltController::show_editor () void SaltController::sync_file_watcher () { - lay::BusySection busy_section; // disable file watcher + tl::FileSystemWatcherDisabled disable_file_watcher; // disable file watcher if (m_file_watcher) { m_file_watcher->clear (); @@ -231,7 +231,7 @@ SaltController::install_packages (const std::vector &packages, bool { // 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 + tl::FileSystemWatcherDisabled disable_file_watcher; // disable file watcher result = manager.execute (0, m_salt); } diff --git a/src/tl/tl/tlFileSystemWatcher.h b/src/tl/tl/tlFileSystemWatcher.h index f6190f208..d7435c261 100644 --- a/src/tl/tl/tlFileSystemWatcher.h +++ b/src/tl/tl/tlFileSystemWatcher.h @@ -140,6 +140,23 @@ private: std::map::iterator m_iter; }; +/** + * @brief A class employing RIIA for locking the file system watcher + */ +class TL_PUBLIC FileSystemWatcherDisabled +{ +public: + FileSystemWatcherDisabled () + { + tl::FileSystemWatcher::global_enable (false); + } + + ~FileSystemWatcherDisabled () + { + tl::FileSystemWatcher::global_enable (true); + } +}; + } #endif diff --git a/src/tl/tl/tlGit.cc b/src/tl/tl/tlGit.cc index d1e100cad..2c8ee8b6a 100644 --- a/src/tl/tl/tlGit.cc +++ b/src/tl/tl/tlGit.cc @@ -116,7 +116,11 @@ fetch_progress (const git_transfer_progress *stats, void *payload) // first half of progress size_t count = size_t (5000.0 * double (stats->received_objects) / double (std::max (1u, stats->total_objects)) + 1e-10); - progress->set (count); + try { + progress->set (count); + } catch (...) { + // TODO: stop + } return 0; } @@ -128,7 +132,11 @@ checkout_progress(const char * /*path*/, size_t cur, size_t tot, void *payload) // first half of progress size_t count = size_t (5000.0 * double (cur) / double (std::max (size_t (1), tot)) + 1e-10); - progress->set (count + 5000u); + try { + progress->set (count + 5000u); + } catch (...) { + // ignore cancel requests (TODO: how to stop?) + } } static void check (int error)