online.git: engine/sc engine/sw

0 views
Skip to first unread message

"Noel Grandin (via cogerrit)"

unread,
2:02 AM (5 hours ago) 2:02 AM
to collaboraon...@googlegroups.com
engine/sc/source/ui/app/scmod.cxx | 15 ++++++++++++++-
engine/sw/source/uibase/app/swdll.cxx | 13 +++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit c05a7781631be89707b44c208991439d0a91340a
Author: Noel Grandin <noel.g...@collabora.co.uk>
AuthorDate: Thu Apr 23 12:58:28 2026 +0200
Commit: Stephan Bergmann <stephan....@collabora.com>
CommitDate: Wed Apr 29 06:02:05 2026 +0000

lsan: fix clipboard leak

Which shows up when running CppunitTest_sc_shapetest
as a leak of ScTransferObj and some friends.

We have to fix this problem in both sc/ and sw/
simultaneously, because both of these modules try to
shut down the underlying itempools, which the other one
might need (yes, sometimes both writer and calc
are initialised in the same process).

Change-Id: Ia007722ef4d72909ddd77c3e5a9b136aa7e420b9
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/1446
Tested-by: Jenkins CPCI <rel...@collaboraoffice.com>
Reviewed-by: Stephan Bergmann <stephan....@collabora.com>

diff --git a/engine/sc/source/ui/app/scmod.cxx b/engine/sc/source/ui/app/scmod.cxx
index 7b77160736c3..46ffd0b2e635 100644
--- a/engine/sc/source/ui/app/scmod.cxx
+++ b/engine/sc/source/ui/app/scmod.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/

+#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
#include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
#include <comphelper/kit.hxx>
#include <comphelper/processfactory.hxx>
@@ -161,7 +162,19 @@ ScModule::ScModule( SfxObjectFactory* pFact ) :

ScModule::~ScModule()
{
- OSL_ENSURE( !m_pSelTransfer, "Selection Transfer object not deleted" );
+ assert( !m_pSelTransfer && "Selection Transfer object not deleted" );
+
+ // Mostly here to prevent leaks during shutdown when running unit tests
+ // Need to clear this early in the shutdown process, because it might hold references
+ // to large complex things like ScDocument.
+ try {
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard =
+ css::datatransfer::clipboard::SystemClipboard::create(
+ comphelper::getProcessComponentContext());
+ xClipboard->setContents( nullptr, nullptr );
+ } catch (css::uno::DeploymentException const&) {
+ // ignore, sometimes happens that UNO is already shutdown by now
+ }

// InputHandler does not need to be deleted (there's none in the App anymore)

diff --git a/engine/sw/source/uibase/app/swdll.cxx b/engine/sw/source/uibase/app/swdll.cxx
index 19974ef409c5..e249a6ab1a8e 100644
--- a/engine/sw/source/uibase/app/swdll.cxx
+++ b/engine/sw/source/uibase/app/swdll.cxx
@@ -29,6 +29,7 @@
#include <init.hxx>
#include <dobjfac.hxx>

+#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <comphelper/configuration.hxx>
#include <unotools/moduleoptions.hxx>
@@ -143,6 +144,18 @@ SwDLL::SwDLL()

SwDLL::~SwDLL() COVERITY_NOEXCEPT_FALSE
{
+ // Mostly here to prevent leaks during shutdown when running unit tests
+ // Need to clear this early in the shutdown process, because it might hold references
+ // to large complex things like ScDocument.
+ try {
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard =
+ css::datatransfer::clipboard::SystemClipboard::create(
+ comphelper::getProcessComponentContext());
+ xClipboard->setContents( nullptr, nullptr );
+ } catch (css::uno::DeploymentException const&) {
+ // ignore, sometimes happens that UNO is already shutdown by now
+ }
+
if (m_pAutoCorrCfg)
{
// fdo#86494 SwAutoCorrect must be deleted before FinitCore

Reply all
Reply to author
Forward
0 new messages