mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Regularly check if graphics is modified when visible on screen (#10596)
In case one cannot rely on QFileSystemWatcher. see https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg199112.html
This commit is contained in:
parent
c779e9806e
commit
ad16347b08
@ -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(); });
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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_);
|
||||
|
Loading…
Reference in New Issue
Block a user