]> git.lyx.org Git - features.git/commitdiff
First step towards fixing some issues noted by Vincent. We record in the
authorRichard Heck <rgheck@comcast.net>
Wed, 21 Jul 2010 21:51:33 +0000 (21:51 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 21 Jul 2010 21:51:33 +0000 (21:51 +0000)
Buffer whether we are exporting or not, rather than rely upon isClone(),
which could be adapted to other purposes. And, of course, someone might
choose locally to disable cloning....

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34999 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/Buffer.h
src/graphics/PreviewLoader.cpp

index 1cd24493fced6dfa250ff89fc2371f39f2b212e7..392efd762a40692ae70285318c6445d36d6a3f80 100644 (file)
@@ -157,7 +157,7 @@ public:
                }
                delete inset;
        }
-
+       
        /// search for macro in local (buffer) table or in children
        MacroData const * getBufferMacro(docstring const & name,
                DocIterator const & pos) const;
@@ -289,7 +289,9 @@ public:
        /// If non zero, this buffer is a clone of existing buffer \p cloned_buffer_
        /// This one is useful for preview detached in a thread.
        Buffer const * cloned_buffer_;
-
+       /// are we in the process of exporting this buffer?
+       mutable bool doing_export;
+       
 private:
        /// So we can force access via the accessors.
        mutable Buffer const * parent_buffer;
@@ -322,7 +324,7 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_,
          read_only(readonly_), filename(file), file_fully_loaded(false),
          toc_backend(owner), macro_lock(false), timestamp_(0),
          checksum_(0), wa_(0), gui_(0), undo_(*owner), bibinfo_cache_valid_(false),
-         cloned_buffer_(cloned_buffer), parent_buffer(0)
+         cloned_buffer_(cloned_buffer), doing_export(false), parent_buffer(0)
 {
        if (!cloned_buffer_) {
                temppath = createBufferTmpDir();
@@ -3260,10 +3262,41 @@ string Buffer::getDefaultOutputFormat() const
 }
 
 
+namespace {
+       // helper class, to guarantee this gets reset properly
+       class MarkAsExporting   {
+       public:
+               MarkAsExporting(Buffer const * buf) : buf_(buf) 
+               {
+                       LASSERT(buf_, /* */);
+                       buf_->setExportStatus(true);
+               }
+               ~MarkAsExporting() 
+               {
+                       buf_->setExportStatus(false);
+               }
+       private:
+               Buffer const * const buf_;
+       };
+}
+
+
+void Buffer::setExportStatus(bool e) const
+{
+       d->doing_export = e;    
+}
+
+
+bool Buffer::isExporting() const
+{
+       return d->doing_export;
+}
+
 
 bool Buffer::doExport(string const & format, bool put_in_tempdir,
        bool includeall, string & result_file) const
 {
+       MarkAsExporting exporting(this);
        string backend_format;
        OutputParams runparams(&params().encoding());
        runparams.flavor = OutputParams::LATEX;
@@ -3460,6 +3493,7 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
 
 bool Buffer::preview(string const & format, bool includeall) const
 {
+       MarkAsExporting exporting(this);
        string result_file;
        // (1) export with all included children (omit \includeonly)
        if (includeall && !doExport(format, true, true))
index 811727e5a856294f2ed97c165f117f25ef3a722e..dafb61ec88e28bf1396ad9dde3b0e65f9470acb4 100644 (file)
@@ -525,6 +525,10 @@ public:
        std::vector<Format const *> exportableFormats(bool only_viewable) const;
        ///
        bool isExportableFormat(std::string const & format) const;
+       /// mark the buffer as busy exporting something, or not
+       void setExportStatus(bool e) const;
+       ///
+       bool isExporting() const;
 
        ///
        typedef std::vector<std::pair<Inset *, ParIterator> > References;
index 8bec4cc922edf5bab7f7f5b8bc4fd402042cddb4..aa54254a676a766503d351791725d9ae3190ad59 100644 (file)
@@ -588,7 +588,7 @@ void PreviewLoader::Impl::startLoading(bool wait)
 
        // For XHTML image export, we need to control the background 
        // color here.
-       ColorCode bg = buffer_.isClone() 
+       ColorCode bg = buffer_.isExporting() 
                       ? Color_white : PreviewLoader::backgroundColor();
        // The conversion command.
        ostringstream cs;