desktop/source/lib/init.cxx | 13 +++++++++++++ include/sfx2/objsh.hxx | 4 ++++ sfx2/source/doc/objxtor.cxx | 5 +++++ 3 files changed, 22 insertions(+)
New commits: commit df27f612240b32242799f3cd57607ce36eaf3162 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Thu Mar 28 09:38:15 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Aug 28 16:14:50 2024 +0200 lok: add method to allow explicit cleanup of temporary files.o Special case fast destruction of background saving children. Change-Id: I8fba4d0818d23a8b0e1bb4d074e1afae7dacde33 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165448 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 7d784910689172014b8cf6144e654402696d8801) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172520 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index d7b7f9f3d429..5241fd4c1673 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1502,6 +1502,19 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference <css::lang::XComponent> xC LibLODocument_Impl::~LibLODocument_Impl() { + if (comphelper::LibreOfficeKit::isForkedChild()) + { + // Touch the least memory possible, while trying to avoid leaking files. + SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + if (pBaseModel) + { + SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); + if (pObjectShell) + pObjectShell->InternalCloseAndRemoveFiles(); + } + return; + } + try { mxComponent->dispose(); diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index d8c25e752955..d0cd3e03dd01 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -241,6 +241,7 @@ private: public: static const css::uno::Sequence<sal_Int8>& getUnoTunnelId(); + /* Stampit disable/enable cancel button for print jobs default = true = enable! */ void Stamp_SetPrintCancelState(bool bState); @@ -706,6 +707,9 @@ public: bool bShowCloseButton = true); std::vector<InfobarData>& getPendingInfobars(); + // Destruction of storages and streams + void InternalCloseAndRemoveFiles(); + SAL_DLLPRIVATE bool CreatePreview_Impl(bool bFullContent, VirtualDevice* pDevice, GDIMetaFile* pFile) const; SAL_DLLPRIVATE static bool IsPackageStorageFormat_Impl(const SfxMedium &); diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 453cc379f60b..fb6e012eb398 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -312,6 +312,11 @@ SfxObjectShell::~SfxObjectShell() if ( pSfxApp && pSfxApp->GetDdeService() ) pSfxApp->RemoveDdeTopic( this ); + InternalCloseAndRemoveFiles(); +} + +void SfxObjectShell::InternalCloseAndRemoveFiles() +{ // don't call GetStorage() here, in case of Load Failure it's possible that a storage was never assigned! if ( pMedium && pMedium->HasStorage_Impl() && pMedium->GetStorage( false ) == pImpl->m_xDocStorage ) pMedium->CanDisposeStorage_Impl( false );