desktop: fix crash in forceSetClipboardForCurrentView()

Crashreport signature:

> Fatal signal received: SIGSEGV code: 1 for address: 0x0
> program/libmergedlo.so
>       (anonymous namespace)::forceSetClipboardForCurrentView(_LibreOfficeKitDocument*)
>               desktop/source/lib/init.cxx:1376 (discriminator 6)
> program/libmergedlo.so
>       rtl::Reference<LOKClipboard>::~Reference()
>               include/rtl/ref.hxx:128
> program/libmergedlo.so
>       com::sun::uno::Reference<com::sun::lang::XComponent>::~Reference()
>               include/com/sun/star/uno/Reference.hxx:113

Sounds like an attempted document load that failed, but we still try to
set the clipboard for the first view during shutdown.

Change-Id: I21e5742ae4fcd4b24daf2888f3d64aae437d4fda
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176812
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
Miklos Vajna 2024-11-19 08:44:12 +01:00
parent b5c5b51e75
commit 6c6e4358ae

View file

@ -1357,6 +1357,10 @@ rtl::Reference<LOKClipboard> forceSetClipboardForCurrentView(LibreOfficeKitDocum
{
ITiledRenderable* pDoc = getTiledRenderable(pThis);
rtl::Reference<LOKClipboard> xClip(LOKClipboardFactory::getClipboardForCurView());
if (!pDoc)
{
return xClip;
}
SAL_INFO("lok", "Set to clipboard for view " << xClip.get());
// FIXME: using a hammer here - should not be necessary if all tests used createView.