Attempt to fix bug #13017.

We should not remove the aux and bbl files when the Buffer is actively being exported.
This commit is contained in:
Richard Kimberly Heck 2023-12-20 20:19:12 -05:00
parent 378397a6c6
commit 92209fb6b8
7 changed files with 37 additions and 3 deletions

View File

@ -2689,6 +2689,11 @@ bool Buffer::citeLabelsValid() const
void Buffer::removeBiblioTempFiles() const void Buffer::removeBiblioTempFiles() const
{ {
if (theApp()->isBufferBusy(this)) {
removeBiblioTemps = true;
return;
}
// We remove files that contain LaTeX commands specific to the // We remove files that contain LaTeX commands specific to the
// particular bibliographic style being used, in order to avoid // particular bibliographic style being used, in order to avoid
// LaTeX errors when we switch style. // LaTeX errors when we switch style.
@ -2702,6 +2707,7 @@ void Buffer::removeBiblioTempFiles() const
Buffer const * const pbuf = parent(); Buffer const * const pbuf = parent();
if (pbuf) if (pbuf)
pbuf->removeBiblioTempFiles(); pbuf->removeBiblioTempFiles();
removeBiblioTemps = false;
} }

View File

@ -806,18 +806,20 @@ public:
/// of loaded child documents). /// of loaded child documents).
docstring_list const & docstring_list const &
getBibfiles(UpdateScope scope = UpdateMaster) const; getBibfiles(UpdateScope scope = UpdateMaster) const;
///
bool needToRemoveBiblioTemps() const { return removeBiblioTemps; }
/// routines for dealing with possible self-inclusion /// routines for dealing with possible self-inclusion
void pushIncludedBuffer(Buffer const * buf) const; void pushIncludedBuffer(Buffer const * buf) const;
void popIncludedBuffer() const; void popIncludedBuffer() const;
bool isBufferIncluded(Buffer const * buf) const; bool isBufferIncluded(Buffer const * buf) const;
private: private:
void clearIncludeList() const; void clearIncludeList() const;
///
private:
friend class MarkAsExporting; friend class MarkAsExporting;
/// mark the buffer as busy exporting something, or not /// mark the buffer as busy exporting something, or not
void setExportStatus(bool e) const; void setExportStatus(bool e) const;
///
mutable bool removeBiblioTemps = false;
/// ///
References & getReferenceCache(docstring const & label); References & getReferenceCache(docstring const & label);

View File

@ -255,6 +255,8 @@ public:
virtual bool unhide(Buffer * buf) = 0; virtual bool unhide(Buffer * buf) = 0;
// Apply preferences at the start // Apply preferences at the start
static void applyPrefs(); static void applyPrefs();
///
virtual bool isBufferBusy(Buffer const * b) = 0;
}; };
/// Return the list of loadable formats. /// Return the list of loadable formats.

View 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) docstring Application::iconName(FuncRequest const & f, bool unknown)
{ {
return qstring_to_ucs4(lyx::frontend::iconInfo(f, unknown, false).filepath); return qstring_to_ucs4(lyx::frontend::iconInfo(f, unknown, false).filepath);

View File

@ -83,6 +83,7 @@ public:
std::string inputLanguageCode() const override; std::string inputLanguageCode() const override;
void handleKeyFunc(FuncCode action) override; void handleKeyFunc(FuncCode action) override;
bool unhide(Buffer * buf) override; bool unhide(Buffer * buf) override;
bool isBufferBusy(Buffer const * b) override;
//@} //@}
/// ///

View File

@ -527,6 +527,7 @@ public:
string last_export_format; string last_export_format;
string processing_format; string processing_format;
// Buffers that are being exported
static QSet<Buffer const *> busyBuffers; static QSet<Buffer const *> busyBuffers;
unsigned int smallIconSize; 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) bool GuiView::saveBuffer(Buffer & b)
{ {
return saveBuffer(b, FileName()); 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. // documents, starting from the master. so we must delete those.
Buffer * mbuf = const_cast<Buffer *>(clone->masterBuffer()); Buffer * mbuf = const_cast<Buffer *>(clone->masterBuffer());
delete mbuf; delete mbuf;
if (orig->needToRemoveBiblioTemps())
orig->removeBiblioTempFiles();
busyBuffers.remove(orig); busyBuffers.remove(orig);
return status; return status;
} }

View File

@ -220,6 +220,8 @@ public:
/// Current ratio between physical pixels and device-independent pixels /// Current ratio between physical pixels and device-independent pixels
double pixelRatio() const; double pixelRatio() const;
///
static bool isBufferBusy(Buffer const * b);
Q_SIGNALS: Q_SIGNALS:
void closing(int); void closing(int);