+void Buffer::Impl::refreshFileMonitor()
+{
+ if (file_monitor_ && file_monitor_->filename() == filename.absFileName())
+ return file_monitor_->refresh();
+
+ // The previous file monitor is invalid
+ // This also destroys the previous file monitor and all its connections
+ file_monitor_ = FileSystemWatcher::monitor(filename);
+ fileExternallyModified(false);
+ // file_monitor_ will be destroyed with *this, so it is not going to call a
+ // destroyed object method.
+ file_monitor_->connect([this](){ fileExternallyModified(true); });
+}
+
+
+void Buffer::Impl::fileExternallyModified(bool modified) const
+{
+ if (modified)
+ lyx_clean = bak_clean = false;
+ externally_modified_ = modified;
+ if (wa_)
+ wa_->updateTitles();
+}
+
+
+bool Buffer::notifiesExternalModification() const
+{
+ return d->isExternallyModified();
+}
+
+
+void Buffer::clearExternalModification() const
+{
+ d->fileExternallyModified(false);
+}
+