From e63ec6c40c9cb6a265c2060c28491405413b3200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com> Date: Fri, 23 Aug 2019 09:44:01 +0200 Subject: [PATCH] Fix old boost build for good With the previous approach the code could lead to crashes in the flowfrm.cxx Change-Id: I3b56ed46db9d37a606a1cd793a20b8aff22db6e2 --- sw/source/core/inc/frame.hxx | 5 +++++ sw/source/core/layout/calcmove.cxx | 9 +++++++-- sw/source/core/layout/flowfrm.cxx | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index ab1047d0348f..312957a02593 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -1238,7 +1238,12 @@ public: //it in e.g. SwSectionFrame::MergeNext etc because we will need it //again after the SwFrameDeleteGuard dtor explicit SwFrameDeleteGuard(SwFrame* pFrame); + + SwFrameDeleteGuard(const SwFrameDeleteGuard&) =delete; + ~SwFrameDeleteGuard(); + + SwFrameDeleteGuard& operator=(const SwFrameDeleteGuard&) =delete; }; typedef long (SwFrame:: *SwFrameGet)() const; diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 3502450c2a47..cb956d8f916c 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -404,14 +404,19 @@ void SwFrame::PrepareCursor() const bool bTab = IsTabFrame(); bool bNoSect = IsInSct(); +#if BOOST_VERSION < 105600 + std::list<FlowFrameJoinLockGuard> tabGuard; + std::list<SwFrameDeleteGuard> rowGuard; +#else boost::optional<FlowFrameJoinLockGuard> tabGuard; boost::optional<SwFrameDeleteGuard> rowGuard; +#endif SwFlowFrame* pThis = bCnt ? static_cast<SwContentFrame*>(this) : nullptr; if ( bTab ) { #if BOOST_VERSION < 105600 - tabGuard.reset(static_cast<SwTabFrame*>(this)); // tdf#125741 + tabGuard.emplace_back(static_cast<SwTabFrame*>(this)); // tdf#125741 #else tabGuard.emplace(static_cast<SwTabFrame*>(this)); // tdf#125741 #endif @@ -420,7 +425,7 @@ void SwFrame::PrepareCursor() else if (IsRowFrame()) { #if BOOST_VERSION < 105600 - rowGuard.reset(SwFrameDeleteGuard(this)); // tdf#125741 keep this alive + rowGuard.emplace_back(this); // tdf#125741 keep this alive #else rowGuard.emplace(this); // tdf#125741 keep this alive #endif diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 54f0bdd4e567..fb87c6025061 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -2522,7 +2522,11 @@ bool SwFlowFrame::MoveBwd( bool &rbReformat ) { auto const pOld = m_rThis.GetUpper(); +#if BOOST_VERSION < 105600 + std::list<SwFrameDeleteGuard> g; +#else ::boost::optional<SwFrameDeleteGuard> g; +#endif if (m_rThis.GetUpper()->IsCellFrame()) { // note: IsFollowFlowRow() is never set for new-style tables @@ -2533,7 +2537,7 @@ bool SwFlowFrame::MoveBwd( bool &rbReformat ) { // lock follow-flow-row (similar to sections above) #if BOOST_VERSION < 105600 - g.reset(SwFrameDeleteGuard(m_rThis.GetUpper()->GetUpper())); + g.emplace_back(m_rThis.GetUpper()->GetUpper()); #else g.emplace(m_rThis.GetUpper()->GetUpper()); #endif -- 2.22.0