]> git.lyx.org Git - features.git/commitdiff
Fix bug #13017.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 11 Jan 2024 22:23:52 +0000 (17:23 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 11 Jan 2024 22:23:52 +0000 (17:23 -0500)
The problem is caused by removing temporary aux, etc, files while
we are in the process of exporting. As Jürgen suggested, we really
do not need to remove these files until we are preparing to export:
They are not used internally. So now we just schedule the removal
and do it then.

src/Buffer.cpp
src/Buffer.h
src/frontends/qt/GuiView.cpp
src/insets/InsetCitation.cpp

index 732ca7e323f109503f546ec17d0d18fbe24cae59..29dfe4bfe233e877170399bda5343dab7c3728ef 100644 (file)
@@ -2444,7 +2444,7 @@ void Buffer::invalidateBibinfoCache() const
 {
        d->bibinfo_cache_valid_ = false;
        d->cite_labels_valid_ = false;
-       removeBiblioTempFiles();
+       scheduleBiblioTempRemoval();
        // also invalidate the cache for the parent buffer
        Buffer const * const pbuf = d->parent();
        if (pbuf)
@@ -2702,6 +2702,7 @@ void Buffer::removeBiblioTempFiles() const
        Buffer const * const pbuf = parent();
        if (pbuf)
                pbuf->removeBiblioTempFiles();
+       removeBiblioTemps = false;
 }
 
 
@@ -4475,6 +4476,8 @@ void Buffer::setMathFlavor(OutputParams & op) const
 Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir,
        bool includeall, string & result_file) const
 {
+       if (removeBiblioTemps)
+               removeBiblioTempFiles();
        LYXERR(Debug::FILES, "target=" << target);
        OutputParams runparams(&params().encoding());
        string format = target;
index de27084af983c9924027d53e6104ba95222739f2..ee37098055a014dcd97e746f60c876fd464e841f 100644 (file)
@@ -538,9 +538,6 @@ public:
        /// dereferenced label name
        void getLabelList(std::vector<std::tuple<docstring, docstring, docstring>> &) const;
 
-       /// This removes the .aux and .bbl files from the temp dir.
-       void removeBiblioTempFiles() const;
-
        ///
        void changeLanguage(Language const * from, Language const * to);
 
@@ -704,6 +701,8 @@ private:
        ///
        ExportStatus doExport(std::string const & target, bool put_in_tempdir,
                std::string & result_file) const;
+       /// This removes the .aux and .bbl files from the temp dir.
+       void removeBiblioTempFiles() const;
        /// target is a format name optionally followed by a space
        /// and a destination file-name
        ExportStatus doExport(std::string const & target, bool put_in_tempdir,
@@ -806,18 +805,20 @@ public:
        /// of loaded child documents).
        docstring_list const &
                getBibfiles(UpdateScope scope = UpdateMaster) const;
-
+       ///
+       void scheduleBiblioTempRemoval() const { removeBiblioTemps = true; }
        /// routines for dealing with possible self-inclusion
        void pushIncludedBuffer(Buffer const * buf) const;
        void popIncludedBuffer() const;
        bool isBufferIncluded(Buffer const * buf) const;
 private:
        void clearIncludeList() const;
-
-private:
+       ///
        friend class MarkAsExporting;
        /// mark the buffer as busy exporting something, or not
        void setExportStatus(bool e) const;
+       ///
+       mutable bool removeBiblioTemps = false;
 
        ///
        References & getReferenceCache(docstring const & label);
index 79ffc0a2071f857e55c160fa5f1e07b870d4c4b9..c2ca3671dd47acea09769640ad16151b92aff690 100644 (file)
@@ -527,6 +527,7 @@ public:
        string last_export_format;
        string processing_format;
 
+       // Buffers that are being exported
        static QSet<Buffer const *> busyBuffers;
 
        unsigned int smallIconSize;
index b1d01f4d67b5fb2856a5213f4f384c425c5c3bcb..5082e112f222fac69218d44a1db5e77e5b295576 100644 (file)
@@ -50,7 +50,7 @@ namespace lyx {
 InsetCitation::InsetCitation(Buffer * buf, InsetCommandParams const & p)
        : InsetCommand(buf, p)
 {
-       buffer().removeBiblioTempFiles();
+       buffer().scheduleBiblioTempRemoval();
        cleanKeys();
 }
 
@@ -61,7 +61,7 @@ InsetCitation::~InsetCitation()
                /* We do not use buffer() because Coverity believes that this
                 * may throw an exception. Actually this code path is not
                 * taken when buffer_ == 0 */
-               buffer_->removeBiblioTempFiles();
+               buffer_->scheduleBiblioTempRemoval();
 }
 
 
@@ -142,7 +142,7 @@ void InsetCitation::doDispatch(Cursor & cur, FuncRequest & cmd)
                openCitation();
                break;
        case LFUN_INSET_MODIFY: {
-               buffer().removeBiblioTempFiles();
+               buffer().scheduleBiblioTempRemoval();
                cache.recalculate = true;
                if (cmd.getArg(0) == "toggleparam") {
                        string cmdname = getCmdName();