sc/source/ui/inc/tabvwsh.hxx | 6 +++--- sc/source/ui/view/reffact.cxx | 2 +- sc/source/ui/view/tabvwshc.cxx | 11 ++++++----- vcl/README.lifecycle | 24 ++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 9 deletions(-)
New commits: commit b6bd432a584c1361ca6277794f8a5466fc01bc52 Author: Michael Meeks <michael.me...@collabora.com> Date: Fri May 8 11:34:22 2015 +0100 vcl: more VclPtr debugging docs in the README.lifecycle. Change-Id: I49d06d54157e1e7c5b7ce2aa3f8917763de6826d diff --git a/vcl/README.lifecycle b/vcl/README.lifecycle index 7c2ceb2..55ec160 100644 --- a/vcl/README.lifecycle +++ b/vcl/README.lifecycle @@ -299,4 +299,28 @@ ways and often both. cleanup methods, especially LoseFocus continue to work even on disposed Window sub-class instances. +** It crashes with some invalid memory ... + + Assuming that the invalid memory is a Window sub-class itself, + then almost certainly there is some cockup in the + reference-counting; eg. if you hit an OutputDevice::release + assert on mnRefCount - then almost certainly you have a + Window that has already been destroyed. This can easily + happen via this sort of pattern: + + ModelessDialog *pDlg = VclPtr<ModelessDialog>(nullptr /* parent */); + // by here the pDlg quite probably points to free'd memory + ... + + It is necessary in these cases to ensure that the *pDlg is + a VclPtr<ModelessDialog> instead. + +** It crashes with some invalid memory #2 ... + + Often a ::dispose method will free some pImpl member, but + not NULL it; and (cf. above) we can now get various virtual + methods called post-dispose; so: + + a) delete pImpl; pImpl = NULL; // in the destructor + b) if (pImpl && ...) // in the subsequently called method commit 087f7fe50b03307e2d9202365886e8c37bd7e6e3 Author: Michael Meeks <michael.me...@collabora.com> Date: Fri May 8 11:33:33 2015 +0100 tdf#91125 - nail a clutch of calc modeless dialog lifecycle issues. Good idea to hold a reference after creation. Change-Id: I450c415259c4011c8b3fb8be715e55643765d9db diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index 4bc50e5..04e21a9 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -356,9 +356,9 @@ public: void DeactivateOle(); SC_DLLPUBLIC static ScTabViewShell* GetActiveViewShell(); - SfxModelessDialog* CreateRefDialog( SfxBindings* pB, SfxChildWindow* pCW, - SfxChildWinInfo* pInfo, - vcl::Window* pParent, sal_uInt16 nSlotId ); + VclPtr<SfxModelessDialog> CreateRefDialog( SfxBindings* pB, SfxChildWindow* pCW, + SfxChildWinInfo* pInfo, + vcl::Window* pParent, sal_uInt16 nSlotId ); void UpdateOleZoom(); inline SbxObject* GetScSbxObject() const diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx index 4ba4eb9..b05db95f 100644 --- a/sc/source/ui/view/reffact.cxx +++ b/sc/source/ui/view/reffact.cxx @@ -90,7 +90,7 @@ namespace pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); \ OSL_ENSURE( pViewShell, "missing view shell :-(" ); \ pWindow = pViewShell ? \ - pViewShell->CreateRefDialog( p, this, pInfo, pParentP, sid ) : NULL; \ + pViewShell->CreateRefDialog( p, this, pInfo, pParentP, sid ) : nullptr; \ if (pViewShell && !pWindow) \ pViewShell->GetViewFrame()->SetChildWindow( nId, false ); \ } diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index fbbfa24..4d5d2d4 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -113,9 +113,10 @@ void ScTabViewShell::SwitchBetweenRefDialogs(SfxModelessDialog* pDialog) } } -SfxModelessDialog* ScTabViewShell::CreateRefDialog( - SfxBindings* pB, SfxChildWindow* pCW, SfxChildWinInfo* pInfo, - vcl::Window* pParent, sal_uInt16 nSlotId ) +VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog( + SfxBindings* pB, SfxChildWindow* pCW, + SfxChildWinInfo* pInfo, + vcl::Window* pParent, sal_uInt16 nSlotId ) { // Dialog nur aufmachen, wenn ueber ScModule::SetRefDialog gerufen, damit // z.B. nach einem Absturz offene Ref-Dialoge nicht wiederkommen (#42341#). @@ -132,7 +133,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( return NULL; } - SfxModelessDialog* pResult = 0; + VclPtr<SfxModelessDialog> pResult; if(pCW) pCW->SetHideNotDelete(true); @@ -156,7 +157,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( ScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() ), &maRangeMap); - static_cast<ScNameDlg*>(pResult)->SetEntry( maName, maScope); + static_cast<ScNameDlg*>(pResult.get())->SetEntry( maName, maScope); mbInSwitch = false; } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits