sc/inc/document.hxx            |    4 ++--
 sc/source/ui/view/viewfun3.cxx |    3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 20ca3feabe51c0173e7aec979a8cd618a0b76466
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Oct 5 14:12:51 2023 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Thu Oct 5 17:29:46 2023 +0200

    crash copying text + chart to clipboard with InputOptions::TextWysiwyg
    
    of true, the mxPoolHelper is still null when trying to create a
    Printer to use as a reference device
    
     #3  0x00007f6d5e81ee6e in ScDocShell::GetRefDevice 
(this=this@entry=0x4697e6e0) at libreoffice/sc/source/ui/docshell/docsh3.cxx:471
     #4  0x00007f6d5e823439 in ScDocShell::UpdateFontList 
(this=this@entry=0x4697e6e0) at libreoffice/sc/source/ui/docshell/docsh3.cxx:462
     #5  0x00007f6d5e81dd6c in ScDocShell::InitItems 
(this=this@entry=0x4697e6e0) at libreoffice/sc/source/ui/docshell/docsh2.cxx:98
     #6  0x00007f6d5e81e80b in ScDocShell::InitNew (this=0x4697e6e0, xStor=...) 
at libreoffice/sc/source/ui/docshell/docsh2.cxx:83
     #7  0x00007f6d6e2ce99d in SfxObjectShell::DoInitNew 
(this=this@entry=0x4697e6e0) at libreoffice/sfx2/source/doc/objstor.cxx:470
     #8  0x00007f6d5e768daf in ScTransferObj::SetDrawClipDoc 
(bAnyOle=<optimized out>, pDoc=std::shared_ptr<ScDocument> (use count 2, weak 
count 0) = {...})
         at libreoffice/sc/source/ui/app/transobj.cxx:821
     #9  0x00007f6d5ec4735a in ScViewFunc::CopyToClipSingleRange 
(this=0x37a257a0, pClipDoc=<optimized out>, rRanges=..., bCut=<optimized out>, 
bIncludeObjects=<optimized out>)
         at libreoffice/sc/source/ui/view/viewfun3.cxx:248
     #10 0x00007f6d5ec48ab0 in ScViewFunc::CopyToClip 
(this=this@entry=0x37a257a0, pClipDoc=pClipDoc@entry=0x0, rRanges=..., 
bCut=bCut@entry=false, bApi=bApi@entry=false,
         bIncludeObjects=bIncludeObjects@entry=true, bStopEdit=true) at 
libreoffice/sc/source/ui/view/viewfun3.cxx:212
     #11 0x00007f6d5ec48dc3 in ScViewFunc::CopyToClip 
(this=this@entry=0x37a257a0, pClipDoc=pClipDoc@entry=0x0, 
bCut=bCut@entry=false, bApi=bApi@entry=false,
         bIncludeObjects=bIncludeObjects@entry=true, 
bStopEdit=bStopEdit@entry=true) at 
libreoffice/sc/source/ui/view/viewfun3.cxx:178
     #12 0x00007f6d5eb0eada in ScCellShell::ExecuteEdit (this=0x35c3d240, 
rReq=...) at libreoffice/sc/source/ui/view/cellsh1.cxx:1369
    
    Change-Id: I1eb90a0190719a0ffe52dcdc5b0d87f5198cd5a9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157611
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 262ad6e1cd8f..74da175a9a99 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2698,6 +2698,8 @@ public:
     const ScTable* FetchTable( SCTAB nTab ) const;
 
     ScRefCellValue GetRefCellValue( const ScAddress& rPos );
+
+    void SharePooledResources( const ScDocument* pSrcDoc );
 private:
     ScRefCellValue GetRefCellValue( const ScAddress& rPos, 
sc::ColumnBlockPosition& rBlockPos );
 
@@ -2707,8 +2709,6 @@ private:
     SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) 
const;
     void   ReservePatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserve );
 
-    void SharePooledResources( const ScDocument* pSrcDoc );
-
     void EndListeningIntersectedGroup(
         sc::EndListeningContext& rCxt, const ScAddress& rPos, 
std::vector<ScAddress>* pGroupPos );
 
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 567447149937..4f5dea599230 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -244,6 +244,9 @@ bool ScViewFunc::CopyToClipSingleRange( ScDocument* 
pClipDoc, const ScRangeList&
     if ( bSysClip && bIncludeObjects )
     {
         bool bAnyOle = rDoc.HasOLEObjectsInArea( aRange );
+        // There are optional paths (e.g. bAnyOle and 
InputOptions().GetTextWysiwyg true)
+        // which dereference pSysClipDoc->mxPoolHelper so ensure that is set 
here.
+        pSysClipDoc->SharePooledResources(&rDoc);
         // Update ScGlobal::xDrawClipDocShellRef.
         ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( 
bAnyOle, pSysClipDoc ) );
     }

Reply via email to