Kaydet (Commit) eee32536 authored tarafından Miklos Vajna's avatar Miklos Vajna

bnc#382137 SwFrm::CheckPageDescs: notify clients about deleted SwPageFrm

The problem is the following: SwLayAction::InternalAction() saves
pPage->GetPrev() as pTmp, then SwFrm::CheckPageDescs(pPage) is called,
which deletes pPage->GetPrev(). SwLayAction has no idea that pTmp got
deleted, and later passes it to unlockPositionOfObjects(), which
obviously assumes a valid pointer.

To be on the safe side, just provide a possibility to let the caller
know its pointer has been deleted.

Change-Id: Ibb4d83266b1f4b6146a12dce0d4701f1056deecd
üst a8b499c9
...@@ -588,7 +588,7 @@ public: ...@@ -588,7 +588,7 @@ public:
inline void SetFixSize( sal_Bool bNew ) { mbFixSize = bNew; } inline void SetFixSize( sal_Bool bNew ) { mbFixSize = bNew; }
// check all pages (starting from the given) and correct them if needed // check all pages (starting from the given) and correct them if needed
static void CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields = sal_True ); static void CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields = sal_True, SwPageFrm** ppPrev = 0);
// might return 0, with and without const // might return 0, with and without const
SwFrm *GetNext() { return mpNext; } SwFrm *GetNext() { return mpNext; }
......
...@@ -562,7 +562,7 @@ void SwLayAction::InternalAction() ...@@ -562,7 +562,7 @@ void SwLayAction::InternalAction()
SwPageFrm *pTmp = pPage->GetPrev() ? SwPageFrm *pTmp = pPage->GetPrev() ?
(SwPageFrm*)pPage->GetPrev() : pPage; (SwPageFrm*)pPage->GetPrev() : pPage;
SetCheckPages( sal_True ); SetCheckPages( sal_True );
SwFrm::CheckPageDescs( pPage ); SwFrm::CheckPageDescs( pPage, sal_True, &pTmp );
SetCheckPages( sal_False ); SetCheckPages( sal_False );
nCheckPageNum = USHRT_MAX; nCheckPageNum = USHRT_MAX;
pPage = pTmp; pPage = pTmp;
......
...@@ -1061,7 +1061,7 @@ void SwPageFrm::PrepareRegisterChg() ...@@ -1061,7 +1061,7 @@ void SwPageFrm::PrepareRegisterChg()
|* einfache zu bereinigen. |* einfache zu bereinigen.
|* |*
|*************************************************************************/ |*************************************************************************/
void SwFrm::CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields ) void SwFrm::CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields, SwPageFrm** ppPrev )
{ {
OSL_ENSURE( pStart, "Keine Startpage." ); OSL_ENSURE( pStart, "Keine Startpage." );
...@@ -1136,10 +1136,15 @@ void SwFrm::CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields ) ...@@ -1136,10 +1136,15 @@ void SwFrm::CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields )
{ {
SwPageFrm *pTmp = (SwPageFrm*)pPage->GetNext(); SwPageFrm *pTmp = (SwPageFrm*)pPage->GetNext();
pPage->Cut(); pPage->Cut();
bool bUpdatePrev = false;
if (ppPrev && *ppPrev == pPage)
bUpdatePrev = true;
delete pPage; delete pPage;
if ( pStart == pPage ) if ( pStart == pPage )
pStart = pTmp; pStart = pTmp;
pPage = pTmp; pPage = pTmp;
if (bUpdatePrev)
*ppPrev = pTmp;
continue; continue;
} }
else if ( pPage->IsEmptyPage() && !pFmtWish && //2. else if ( pPage->IsEmptyPage() && !pFmtWish && //2.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment