[Libreoffice-commits] core.git: Branch 'libreoffice-7-2-3' - sw/source

2021-11-18 Thread Michael Stahl (via logerrit)
 sw/source/core/docnode/ndnum.cxx |2 ++
 sw/source/core/docnode/nodes.cxx |   18 --
 2 files changed, 14 insertions(+), 6 deletions(-)

New commits:
commit f7a148cf13cab1505e0ca8229f6cb334662ef20b
Author: Michael Stahl 
AuthorDate: Mon Nov 15 17:29:59 2021 +0100
Commit: Adolfo Jayme Barrientos 
CommitDate: Thu Nov 18 10:49:57 2021 +0100

tdf#121546 sw: don't use undo array's m_pOutlineNodes

It's pointless.

Change-Id: I304c123bffc16e6133d2953bc9a4f7a3afad14ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124999
Tested-by: Jenkins
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125260
(cherry picked from commit 74ff78e1e21dc83099d0dfcedba780c176c8fb3f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125143
Reviewed-by: Xisco Fauli 
Reviewed-by: Adolfo Jayme Barrientos 
Tested-by: Adolfo Jayme Barrientos 

diff --git a/sw/source/core/docnode/ndnum.cxx b/sw/source/core/docnode/ndnum.cxx
index b3d66affa66e..a7b898ee5f0a 100644
--- a/sw/source/core/docnode/ndnum.cxx
+++ b/sw/source/core/docnode/ndnum.cxx
@@ -38,6 +38,8 @@ bool SwOutlineNodes::Seek_Entry(SwNode* rP, size_type* pnPos) 
const
 
 void SwNodes::UpdateOutlineNode(SwNode & rNd)
 {
+assert(IsDocNodes()); // no point in m_pOutlineNodes for undo nodes
+
 SwTextNode * pTextNd = rNd.GetTextNode();
 
 if (!(pTextNd && pTextNd->IsOutlineStateChanged()))
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index da593261074b..e7af18a1c16a 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -110,6 +110,16 @@ SwNodes::~SwNodes()
 m_pEndOfContent.reset();
 }
 
+static bool IsInsertOutline(SwNodes const& rNodes, sal_uLong const nIndex)
+{
+if (!rNodes.IsDocNodes())
+{
+return false;
+}
+return nIndex < rNodes.GetEndOfRedlines().StartOfSectionNode()->GetIndex()
+|| rNodes.GetEndOfRedlines().GetIndex() < nIndex;
+}
+
 void SwNodes::ChgNode( SwNodeIndex const & rDelPos, sal_uLong nSz,
 SwNodeIndex& rInsPos, bool bNewFrames )
 {
@@ -125,9 +135,7 @@ void SwNodes::ChgNode( SwNodeIndex const & rDelPos, 
sal_uLong nSz,
 
 // NEVER include nodes from the RedLineArea
 sal_uLong nNd = rInsPos.GetIndex();
-bool bInsOutlineIdx = (
-rNds.GetEndOfRedlines().StartOfSectionNode()->GetIndex() >= nNd ||
-nNd >= rNds.GetEndOfRedlines().GetIndex() );
+bool const bInsOutlineIdx = IsInsertOutline(rNds, nNd);
 
 if(  == this ) // if in the same node array -> move
 {
@@ -484,9 +492,7 @@ bool SwNodes::MoveNodes( const SwNodeRange& aRange, SwNodes 
& rNodes,
 
 // NEVER include nodes from the RedLineArea
 sal_uLong nNd = aIdx.GetIndex();
-bool bInsOutlineIdx = ( rNodes.GetEndOfRedlines().
-StartOfSectionNode()->GetIndex() >= nNd ||
-nNd >= rNodes.GetEndOfRedlines().GetIndex() );
+bool const bInsOutlineIdx = IsInsertOutline(rNodes, nNd);
 
 if( bNewFrames )
 // delete all frames


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2-3' - sw/source

2021-11-12 Thread Julien Nabet (via logerrit)
 sw/source/uibase/uno/unotxdoc.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 3bc5a4c89e54138f6eebecddf93d55f1b052c42a
Author: Julien Nabet 
AuthorDate: Wed Nov 10 22:56:53 2021 +0100
Commit: Xisco Fauli 
CommitDate: Fri Nov 12 09:02:08 2021 +0100

tdf#145584: fix crash on exporting as PDF with Selection rRange

Regression from 20ddabc88b6b45ea3efcc44ede5244ea526b09c4
tdf#144989 sw: disable idle jobs during printing or PDF export
The problem is that (with the kde5 and WNT vclplugs) the idle jobs
update fields and un-hides every section, which destroys the layout
that SwXTextDocument::getRendererCount() finalised with great effort

bt:
0  0x7f773af65dfa in SwXTextDocument::render(int, 
com::sun::star::uno::Any const&, 
com::sun::star::uno::Sequence const&) 
(this=0x66e4980, nRenderer=0, rSelection=
  uno::Any("com.sun.star.uno.XInterface": {_vptr$XInterface = 0x9579020}), 
rxOptions=uno::Sequence of length 8 = {...}) at 
sw/source/uibase/uno/unotxdoc.cxx:3012
1  0x7f76ff5f2832 in PDFExport::ExportSelection(vcl::PDFWriter&, 
com::sun::star::uno::Reference const&, 
com::sun::star::uno::Any const&, StringRangeEnumerator const&, 
com::sun::star::uno::Sequence&, int) 
(this=0x7ffc7ee0e990, rPDFWriter=..., rRenderable=uno::Reference to 
(SwXTextDocument *) 0x66e4c38, rSelection=
  uno::Any("com.sun.star.uno.XInterface": {_vptr$XInterface = 0x9579020}), 
rRangeEnum=..., rRenderOptions=uno::Sequence of length 8 = {...}, nPageCount=1) 
at filter/source/pdf/pdfexport.cxx:218
2  0x7f76ff5f787e in PDFExport::Export(rtl::OUString const&, 
com::sun::star::uno::Sequence const&)
(this=0x7ffc7ee0e990, rFile="file:///tmp/lu4uimg.tmp/lu4uimk.tmp", 
rFilterData=uno::Sequence of length 54 = {...}) at 
filter/source/pdf/pdfexport.cxx:949
3  0x7f76ff60a4a8 in 
PDFFilter::implExport(com::sun::star::uno::Sequence
 const&) (this=0x71798a0, rDescriptor=uno::Sequence of length 14 = {...})
at filter/source/pdf/pdffilter.cxx:161
4  0x7f76ff60a7fe in 
PDFFilter::filter(com::sun::star::uno::Sequence
 const&) (this=0x71798a0, rDescriptor=uno::Sequence of length 14 = {...})
at filter/source/pdf/pdffilter.cxx:224
5  0x7f7755e60218 in SfxObjectShell::ExportTo(SfxMedium&) 
(this=0x66d2a30, rMedium=...) at sfx2/source/doc/objstor.cxx:2468
(full bt here:
https://bugs.documentfoundation.org/attachment.cgi?id=176170)

Valgrind:
==619070== Invalid read of size 8
==619070==at 0x19227A60: SwXTextDocument::render(int, 
com::sun::star::uno::Any const&, 
com::sun::star::uno::Sequence const&) 
(unotxdoc.cxx:3012)
==619070==by 0x7403: ???
==619070==by 0x1C4A8B57: ???
==619070==by 0x1C4A8BFF: ???
==619070==  Address 0x1ed27e08 is 328 bytes inside a block of size 880 
free'd
==619070==at 0x483C71B: operator delete(void*) (vg_replace_malloc.c:923)
==619070==by 0x188EC5CC: SwDoc::release() (doc.cxx:118)
==619070==by 0x1902B92C: clear (ref.hxx:196)
==619070==by 0x1902B92C: SwDocShell::RemoveLink() (docshini.cxx:444)
==619070==by 0x1902B622: SwDocShell::~SwDocShell() (docshini.cxx:372)
==619070==by 0x1902BC07: ~SwDocShell (docshini.cxx:362)
==619070==by 0x1902BC07: ~SwDocShell (docshini.cxx:362)
==619070==by 0x1902BC07: virtual thunk to SwDocShell::~SwDocShell() 
(docshini.cxx:0)
==619070==by 0x18EFA411: ~SfxObjectShellLock (objsh.hxx:863)
==619070==by 0x18EFA411: SwRenderData::~SwRenderData() 
(printdata.cxx:48)
==619070==by 0x19227A2B: operator() (unique_ptr.h:85)
==619070==by 0x19227A2B: reset (unique_ptr.h:182)
==619070==by 0x19227A2B: reset (unique_ptr.h:456)
==619070==by 0x19227A2B: SwXTextDocument::render(int, 
com::sun::star::uno::Any const&, 
com::sun::star::uno::Sequence const&) 
(unotxdoc.cxx:3009)
==619070==by 0x21566DB5: PDFExport::ExportSelection(vcl::PDFWriter&, 
com::sun::star::uno::Reference const&, 
com::sun::star::uno::Any const&, StringRangeEnumerator const&, 
com::sun::star::uno::Sequence&, int) 
(pdfexport.cxx:218)
==619070==by 0x2156BB83: PDFExport::Export(rtl::OUString const&, 
com::sun::star::uno::Sequence const&) 
(pdfexport.cxx:949)
==619070==by 0x21572A05: 
PDFFilter::implExport(com::sun::star::uno::Sequence
 const&) (pdffilter.cxx:161)
==619070==by 0x21572F65: 
PDFFilter::filter(com::sun::star::uno::Sequence
 const&) (pdffilter.cxx:224)
(full Valgrind trace here:
https://bugs.documentfoundation.org/attachment.cgi?id=176173)

Change-Id: I03a7ec45a62be2729273111a37c1d3bdf664
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125014
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 196ac5f5435dfba5bb93e1728c38eb7fa847876d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124976
Reviewed-by: Noel Grandin 
  

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2-3' - sw/source

2021-11-06 Thread Michael Stahl (via logerrit)
 sw/source/uibase/uno/unotxdoc.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 1482b0166dda75c978752ea93b0cd9b76315d384
Author: Michael Stahl 
AuthorDate: Thu Nov 4 18:50:42 2021 +0100
Commit: Caolán McNamara 
CommitDate: Sat Nov 6 17:01:41 2021 +0100

tdf#144989 sw: disable idle jobs during printing or PDF export

The problem is that (with the kde5 and WNT vclplugs) the idle jobs
update fields and un-hides every section, which destroys the layout
that SwXTextDocument::getRendererCount() finalised with great effort.

This doesn't seem to happen with gtk3 or gen vclplugs.

 6  SwSectionNode::MakeOwnFrames(SwNodeIndex*, SwNodeIndex*)
 7  SwSectionFormat::MakeFrames()
 8  SwSection::ImplSetHiddenFlag(bool, bool)
 9  SwSection::SetCondHidden(bool)
 10 SwDocUpdateField::MakeFieldList_(SwDoc&, int)
 11 SwDocUpdateField::MakeFieldList(SwDoc&, bool, int)
 12 sw::DocumentFieldsManager::UpdateExpFields(SwTextField*, bool)
 13 sw::DocumentTimerManager::DoIdleJobs(Timer*)
 14 sw::DocumentTimerManager::LinkStubDoIdleJobs(void*, Timer*)
 15 Link::Call(Timer*) const
 16 Timer::Invoke()
 17 Scheduler::CallbackTaskScheduling() ()
 18 SalTimer::CallCallback()
 19 QtTimer::timeoutActivated()
 20 QtTimer::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)
 21 void doActivate(QObject*, int, void**) ()
 22 QTimer::timeout(QTimer::QPrivateSignal) ()
 23 QObject::event(QEvent*) ()
 24 QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
 25 QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
 26 QTimerInfoList::activateTimers() ()
 27 timerSourceDispatch()
 28 g_main_context_dispatch ()
 29 g_main_context_iterate.constprop ()
 30 g_main_context_iteration ()
 31 
QEventDispatcherGlib::processEvents(QFlags) ()
 32 QtInstance::ImplYield(bool, bool)
 33 QtInstance::DoYield(bool, bool)
 34 ImplYield(bool, bool)
 35 Application::Reschedule(bool)
 36 framework::StatusIndicatorFactory::impl_reschedule(bool)
 37 framework::StatusIndicatorFactory::setValue()
 38 framework::StatusIndicator::setValue(int)
 39 PDFExport::ExportSelection()
 40 PDFExport::Export()

Reportedly this started to happen with commit
4184569b963877c2a488ff05766654b9db194798 - presumably before that the
word counting was so slow that the idle didn't progress to updating
fields.

There is little point in running idle jobs during printing anyway as in
the best case it will just slow down the process.

So temporarily disable the idle jobs in getRendererCount() and
enable it again in render() with "IsLastPage" set.

Change-Id: I6359592aefeec298c5e58d44bef5ef16c583ddac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124721
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 20ddabc88b6b45ea3efcc44ede5244ea526b09c4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124693
Reviewed-by: Caolán McNamara 
(cherry picked from commit 73d3639304100d50422435745f8ecc7ff1583de1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124694
Reviewed-by: Xisco Fauli 
Reviewed-by: Thorsten Behrens 
Tested-by: Caolán McNamara 

diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 890ccdd8fcc3..326787dea7b5 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -2635,6 +2635,10 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
 }
 }
 OSL_ENSURE( nRet >= 0, "negative number of pages???" );
+// tdf#144989 the layout is complete now - prevent DoIdleJobs() from
+// messing it up, particulary SwDocUpdateField::MakeFieldList_() unhiding
+// sections
+pDoc->getIDocumentTimerAccess().BlockIdling();
 
 return nRet;
 }
@@ -3060,6 +3064,8 @@ void SAL_CALL SwXTextDocument::render(
 {
 m_pRenderData.reset();
 m_pPrintUIOptions.reset();
+// tdf#144989 enable DoIdleJobs() again after last page
+pDoc->getIDocumentTimerAccess().UnblockIdling();
 }
 }