commit e3a13968139a7b9469060e2f10b7807c8e10339b
Author: Guillaume Munch <[email protected]>
Date:   Mon Mar 6 23:16:04 2017 +0100

    Replace FileMonitor with FileMonitor2 in GraphicsCacheItem
    
    Remove dead code
---
 src/graphics/GraphicsCacheItem.cpp |   25 +++++++++++++------------
 src/graphics/GraphicsCacheItem.h   |    8 +-------
 src/graphics/GraphicsLoader.cpp    |    9 ---------
 src/graphics/GraphicsLoader.h      |    5 -----
 4 files changed, 14 insertions(+), 33 deletions(-)

diff --git a/src/graphics/GraphicsCacheItem.cpp 
b/src/graphics/GraphicsCacheItem.cpp
index c698168..9eb449a 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 ee2348d..b6d7d41 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<void()> sig_type;
-       typedef sig_type::slot_type slot_type;
+       typedef boost::signals2::signal<void()>::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 987a973..617ce24 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 8b97114..0b58857 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;

Reply via email to