From 59b08c8171d751aafe1aa34b9c1acce5406cc880 Mon Sep 17 00:00:00 2001 From: Richard Kimberly Heck Date: Thu, 11 Jan 2024 17:23:52 -0500 Subject: [PATCH] Fix bug #13017. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 5 ++++- src/Buffer.h | 13 +++++++------ src/frontends/qt/GuiView.cpp | 1 + src/insets/InsetCitation.cpp | 6 +++--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 732ca7e323..29dfe4bfe2 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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(¶ms().encoding()); string format = target; diff --git a/src/Buffer.h b/src/Buffer.h index de27084af9..ee37098055 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -538,9 +538,6 @@ public: /// dereferenced label name void getLabelList(std::vector> &) 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); diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index 79ffc0a207..c2ca3671dd 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -527,6 +527,7 @@ public: string last_export_format; string processing_format; + // Buffers that are being exported static QSet busyBuffers; unsigned int smallIconSize; diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index b1d01f4d67..5082e112f2 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -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(); -- 2.39.5