]> git.lyx.org Git - lyx.git/commitdiff
Regularly check if graphics is modified when visible on screen (#10596)
authorGuillaume Munch <gm@lyx.org>
Sun, 19 Mar 2017 13:41:54 +0000 (14:41 +0100)
committerGuillaume Munch <gm@lyx.org>
Sun, 19 Mar 2017 13:41:54 +0000 (14:41 +0100)
In case one cannot rely on QFileSystemWatcher.

see https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg199112.html

src/graphics/GraphicsCacheItem.cpp
src/graphics/GraphicsCacheItem.h
src/graphics/GraphicsLoader.cpp
src/graphics/GraphicsLoader.h
src/insets/RenderGraphic.cpp

index 0bd3779a4f0042a4ce052215dae962afb62e1531..4ed496a533d52d671b983e74a900e8891f219e05 100644 (file)
@@ -99,7 +99,7 @@ public:
        /// The document filename this graphic item belongs to
        FileName const & doc_file_;
        ///
-       FileMonitorPtr monitor_;
+       ActiveFileMonitorPtr monitor_;
 
        /// Is the file compressed?
        bool zipped_;
@@ -179,6 +179,14 @@ bool CacheItem::monitoring() const
 }
 
 
+void CacheItem::checkModifiedAsync() const
+{
+       if (!pimpl_->monitor_)
+               return;
+       pimpl_->monitor_->checkModifiedAsync();
+}
+
+
 Image const * CacheItem::image() const
 {
        return pimpl_->image_.get();
@@ -214,7 +222,7 @@ void CacheItem::Impl::startMonitor()
 {
        if (monitor_)
                return;
-       monitor_ = FileSystemWatcher::monitor(filename_);
+       monitor_ = FileSystemWatcher::activeMonitor(filename_);
        monitor_->connect([=](){ startLoading(); });
 }
 
index b6d7d4164ca0411e7fd0b44503f0e69a7875348d..9cee2b872e61524d67baf57f2d7c146628cff78c 100644 (file)
@@ -66,6 +66,8 @@ public:
        void startMonitoring() const;
        ///
        bool monitoring() const;
+       /// perform a modification check asynchronously
+       void checkModifiedAsync() const;
 
        /** Get the image associated with filename().
         *  If the image is not yet loaded, returns 0.
index 617ce24fd0ae907c2bb15cdd6bbd93c084063238..26b4e5717e2616f050e1c0f74847c42d9cb0527f 100644 (file)
@@ -328,6 +328,15 @@ bool Loader::monitoring() const
 }
 
 
+void Loader::checkModifiedAsync() const
+{
+       if (!pimpl_->cached_item_)
+               return;
+
+       pimpl_->cached_item_->checkModifiedAsync();
+}
+
+
 FileName const & Loader::filename() const
 {
        static FileName const empty;
index 0b5885772e0e74528e80b9f16c95579c29f71d51..62ea303b34764e7b627c6cba3f152c9387b1a71e 100644 (file)
@@ -81,6 +81,8 @@ public:
        void startMonitoring() const;
        ///
        bool monitoring() const;
+       ///
+       void checkModifiedAsync() const;
 
        /// How far have we got in loading the image?
        ImageStatus status() const;
index 7ab14cb63f6fdb5deacc913d83b5c212a944118c..d48e4771e973e4f725aadbd8c01ace39955f5ec1 100644 (file)
@@ -142,6 +142,7 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
                        loader_.startLoading();
                if (!loader_.monitoring())
                        loader_.startMonitoring();
+               loader_.checkModifiedAsync();
        }
 
        bool const image_ready = displayGraphic(params_) && readyToDisplay(loader_);