From: Guillaume Munch Date: Mon, 6 Mar 2017 22:16:04 +0000 (+0100) Subject: Replace FileMonitor with FileMonitor2 in GraphicsCacheItem X-Git-Tag: 2.3.0alpha1~234 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e3a13968139a7b9469060e2f10b7807c8e10339b;p=lyx.git Replace FileMonitor with FileMonitor2 in GraphicsCacheItem Remove dead code --- diff --git a/src/graphics/GraphicsCacheItem.cpp b/src/graphics/GraphicsCacheItem.cpp index c698168dee..9eb449a1f8 100644 --- a/src/graphics/GraphicsCacheItem.cpp +++ b/src/graphics/GraphicsCacheItem.cpp @@ -45,6 +45,8 @@ public: /// Impl(FileName const & file, FileName const & doc_file); + void startMonitor(); + /** * If no file conversion is needed, then tryDisplayFormat() calls * loadImage() directly. @@ -97,7 +99,7 @@ public: /// The document filename this graphic item belongs to FileName const & doc_file_; /// - FileMonitor const monitor_; + FileMonitorPtr monitor_; /// Is the file compressed? bool zipped_; @@ -167,20 +169,13 @@ void CacheItem::startLoading() const void CacheItem::startMonitoring() const { - if (!pimpl_->monitor_.monitoring()) - pimpl_->monitor_.start(); + pimpl_->startMonitor(); } bool CacheItem::monitoring() const { - return pimpl_->monitor_.monitoring(); -} - - -unsigned long CacheItem::checksum() const -{ - return pimpl_->monitor_.checksum(); + return (bool)pimpl_->monitor_; } @@ -209,12 +204,18 @@ boost::signals2::connection CacheItem::connect(slot_type const & slot) const CacheItem::Impl::Impl(FileName const & file, FileName const & doc_file) : filename_(file), doc_file_(doc_file), - monitor_(file, 2000), zipped_(false), remove_loaded_file_(false), status_(WaitingToLoad) +{} + + +void CacheItem::Impl::startMonitor() { - monitor_.connect(bind(&Impl::startLoading, this)); + if (monitor_) + return; + monitor_ = FileSystemWatcher::monitor(filename_); + monitor_->connect([=](){ startLoading(); }); } diff --git a/src/graphics/GraphicsCacheItem.h b/src/graphics/GraphicsCacheItem.h index ee2348d8fc..b6d7d4164c 100644 --- a/src/graphics/GraphicsCacheItem.h +++ b/src/graphics/GraphicsCacheItem.h @@ -66,11 +66,6 @@ public: void startMonitoring() const; /// bool monitoring() const; - /** Returns the check checksum of filename() so that, for example, you can - * ascertain whether to output a new PostScript version of the file - * for a LaTeX run. - */ - unsigned long checksum() const; /** Get the image associated with filename(). * If the image is not yet loaded, returns 0. @@ -85,8 +80,7 @@ public: /** Connect and you'll be informed when the loading status of the image * changes. */ - typedef boost::signals2::signal sig_type; - typedef sig_type::slot_type slot_type; + typedef boost::signals2::signal::slot_type slot_type; /// boost::signals2::connection connect(slot_type const &) const; diff --git a/src/graphics/GraphicsLoader.cpp b/src/graphics/GraphicsLoader.cpp index 987a973139..617ce24fd0 100644 --- a/src/graphics/GraphicsLoader.cpp +++ b/src/graphics/GraphicsLoader.cpp @@ -328,15 +328,6 @@ bool Loader::monitoring() const } -unsigned long Loader::checksum() const -{ - if (!pimpl_->cached_item_) - return 0; - - return pimpl_->cached_item_->checksum(); -} - - FileName const & Loader::filename() const { static FileName const empty; diff --git a/src/graphics/GraphicsLoader.h b/src/graphics/GraphicsLoader.h index 8b97114f60..0b5885772e 100644 --- a/src/graphics/GraphicsLoader.h +++ b/src/graphics/GraphicsLoader.h @@ -81,11 +81,6 @@ public: void startMonitoring() const; /// bool monitoring() const; - /** Returns the check checksum of filename() so that, for example, you can - * ascertain whether to output a new PostScript version of the file - * for a LaTeX run. - */ - unsigned long checksum() const; /// How far have we got in loading the image? ImageStatus status() const;