]> git.lyx.org Git - lyx.git/commitdiff
Attempt to fix bug #13017. bugs/13017
authorRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 21 Dec 2023 01:19:12 +0000 (20:19 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 21 Dec 2023 01:19:12 +0000 (20:19 -0500)
We should not remove the aux and bbl files when the Buffer is actively being exported.

src/Buffer.cpp
src/Buffer.h
src/frontends/Application.h
src/frontends/qt/GuiApplication.cpp
src/frontends/qt/GuiApplication.h
src/frontends/qt/GuiView.cpp
src/frontends/qt/GuiView.h

index 732ca7e323f109503f546ec17d0d18fbe24cae59..7522dce4343938d433bf26fed31bada34d1be385 100644 (file)
@@ -2689,6 +2689,11 @@ bool Buffer::citeLabelsValid() const
 
 void Buffer::removeBiblioTempFiles() const
 {
+       if (theApp()->isBufferBusy(this)) {
+               removeBiblioTemps = true;
+               return;
+       }
+
        // We remove files that contain LaTeX commands specific to the
        // particular bibliographic style being used, in order to avoid
        // LaTeX errors when we switch style.
@@ -2702,6 +2707,7 @@ void Buffer::removeBiblioTempFiles() const
        Buffer const * const pbuf = parent();
        if (pbuf)
                pbuf->removeBiblioTempFiles();
+       removeBiblioTemps = false;
 }
 
 
index de27084af983c9924027d53e6104ba95222739f2..0ebd2f64ebf326b4c22da208b6675cac514adef3 100644 (file)
@@ -806,18 +806,20 @@ public:
        /// of loaded child documents).
        docstring_list const &
                getBibfiles(UpdateScope scope = UpdateMaster) const;
-
+       ///
+       bool needToRemoveBiblioTemps() const { return removeBiblioTemps; }
        /// 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 75298ca67af4e77f1032746a44d20c3e1f3c8519..429b322baf1e046b12dede3b36981c064565bb9c 100644 (file)
@@ -255,6 +255,8 @@ public:
        virtual bool unhide(Buffer * buf) = 0;
        // Apply preferences at the start
        static void applyPrefs();
+       ///
+       virtual bool isBufferBusy(Buffer const * b) = 0;
 };
 
 /// Return the list of loadable formats.
index 26288a5f55dd1cf148b1153fa56493f947480c7f..9e3cd7039280a5bf7ebc140407e8e4cb0ae465bc 100644 (file)
@@ -1258,6 +1258,18 @@ void GuiApplication::clearSession()
 }
 
 
+bool GuiApplication::isBufferBusy(Buffer const * b)
+{
+       Buffer const * buf = b;
+       while (buf) {
+               if (GuiView::isBufferBusy(b))
+                       return true;
+               buf = buf->parent();
+       }
+       return false;
+}
+
+
 docstring Application::iconName(FuncRequest const & f, bool unknown)
 {
        return qstring_to_ucs4(lyx::frontend::iconInfo(f, unknown, false).filepath);
index b27964dde4ceaa0c88e68d4da4fcb0b6d03ab370..8adaa701c164336ff1eadc28544578850f5c6db0 100644 (file)
@@ -83,6 +83,7 @@ public:
        std::string inputLanguageCode() const override;
        void handleKeyFunc(FuncCode action) override;
        bool unhide(Buffer * buf) override;
+       bool isBufferBusy(Buffer const * b) override;
        //@}
 
        ///
index 79ffc0a2071f857e55c160fa5f1e07b870d4c4b9..5a5c1dac8d8026f33d73120eed6d3405125e1a96 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;
@@ -3451,6 +3452,12 @@ bool GuiView::exportBufferAs(Buffer & b, docstring const & iformat)
 }
 
 
+bool GuiView::isBufferBusy(Buffer const * b)
+{
+       return GuiViewPrivate::busyBuffers.contains(b);
+}
+
+
 bool GuiView::saveBuffer(Buffer & b)
 {
        return saveBuffer(b, FileName());
@@ -4227,6 +4234,8 @@ Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func,
        // documents, starting from the master. so we must delete those.
        Buffer * mbuf = const_cast<Buffer *>(clone->masterBuffer());
        delete mbuf;
+       if (orig->needToRemoveBiblioTemps())
+               orig->removeBiblioTempFiles();
        busyBuffers.remove(orig);
        return status;
 }
index d55472d2670978c5ee29cbe2577555168469c027..42bc1878c5fecf6a17c58d95f792844aadcbc526 100644 (file)
@@ -220,6 +220,8 @@ public:
 
        /// Current ratio between physical pixels and device-independent pixels
        double pixelRatio() const;
+       ///
+       static bool isBufferBusy(Buffer const * b);
 
 Q_SIGNALS:
        void closing(int);