diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-06 19:25:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-07 07:51:25 +0200 |
commit | e040894fbe0765883e13d51fd6d6331adb09832c (patch) | |
tree | d3cc19ec7add92ed751d7051b6cc52e15d91899a | |
parent | d5c6087979a6a01c16eff6dab15b4b94770a2c14 (diff) |
tdf#118554 sc crash clicking outside of comments
regression from
commit c7f762973d21118ce3f5b0baab8850dc89bc4765
loplugin:useuniqueptr in ScTabView
Change-Id: If7fd580f1a2fedbc6b707f59f196cbceffc95fe3
Reviewed-on: https://gerrit.libreoffice.org/57090
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sc/source/ui/inc/tabview.hxx | 11 | ||||
-rw-r--r-- | sc/source/ui/view/tabview5.cxx | 15 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh2.cxx | 23 |
3 files changed, 29 insertions, 20 deletions
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index 52f838705a13..cc8dd64568c9 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -148,7 +148,10 @@ private: Size aFrameSize; // passed on as for DoResize Point aBorderPos; - std::unique_ptr<FuPoor> pDrawActual; + // The ownership of these two is rather weird. we seem to need + // to keep an old copy alive for some period of time to avoid crashing. + FuPoor* pDrawActual; + FuPoor* pDrawOld; std::array<VclPtr<ScGridWindow>, 4> pGridWin; std::array<VclPtr<ScColBar>, 2> pColBar; @@ -325,8 +328,10 @@ public: bool IsDrawSelMode() const { return bDrawSelMode; } void SetDrawSelMode(bool bNew) { bDrawSelMode = bNew; } - void SetDrawFuncPtr(std::unique_ptr<FuPoor> pFuncPtr); - FuPoor* GetDrawFuncPtr() { return pDrawActual.get(); } + void SetDrawFuncPtr(FuPoor* pFuncPtr) { pDrawActual = pFuncPtr; } + void SetDrawFuncOldPtr(FuPoor* pFuncPtr) { pDrawOld = pFuncPtr; } + FuPoor* GetDrawFuncPtr() { return pDrawActual; } + FuPoor* GetDrawFuncOldPtr() { return pDrawOld; } void DrawDeselectAll(); void DrawMarkListHasChanged(); diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index 6900ce9fc430..962fc20e5c9f 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -131,6 +131,7 @@ void ScTabView::Init() // UpdateShow is done during resize or a copy of an existing view from ctor pDrawActual = nullptr; + pDrawOld = nullptr; // DrawView cannot be create in the TabView - ctor // when the ViewShell isn't constructed yet... @@ -158,7 +159,10 @@ ScTabView::~ScTabView() pPageBreakData.reset(); - pDrawActual.reset(); + delete pDrawActual; + pDrawActual = nullptr; + delete pDrawOld; + pDrawOld = nullptr; if (comphelper::LibreOfficeKit::isActive()) { @@ -246,7 +250,7 @@ void ScTabView::MakeDrawView( TriState nForceDesignMode ) // so that immediately can be drawn } SfxRequest aSfxRequest(SID_OBJECT_SELECT, SfxCallMode::SLOT, aViewData.GetViewShell()->GetPool()); - SetDrawFuncPtr(o3tl::make_unique<FuSelection>(*aViewData.GetViewShell(), GetActiveWin(), pDrawView, + SetDrawFuncPtr(new FuSelection(*aViewData.GetViewShell(), GetActiveWin(), pDrawView, pLayer,aSfxRequest)); // used when switching back from page preview: restore saved design mode state @@ -684,11 +688,4 @@ void ScTabView::OnLOKNoteStateChanged(const ScPostIt* pNote) } } -void ScTabView::SetDrawFuncPtr(std::unique_ptr<FuPoor> pNew) -{ - if (pDrawActual) - pDrawActual->Deactivate(); - pDrawActual = std::move(pNew); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx index c93c46970727..b6c4b6a005a7 100644 --- a/sc/source/ui/view/tabvwsh2.cxx +++ b/sc/source/ui/view/tabvwsh2.cxx @@ -199,7 +199,14 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) } if (pTabView->GetDrawFuncPtr()) + { + if (pTabView->GetDrawFuncOldPtr() != pTabView->GetDrawFuncPtr()) + delete pTabView->GetDrawFuncOldPtr(); + + pTabView->GetDrawFuncPtr()->Deactivate(); + pTabView->SetDrawFuncOldPtr(pTabView->GetDrawFuncPtr()); pTabView->SetDrawFuncPtr(nullptr); + } SfxRequest aNewReq(rReq); aNewReq.SetSlot(nDrawSfxId); @@ -211,7 +218,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) case SID_OBJECT_SELECT: // not always switch back if(pView->GetMarkedObjectList().GetMarkCount() == 0) SetDrawShell(bEx); - pTabView->SetDrawFuncPtr(o3tl::make_unique<FuSelection>(*this, pWin, pView, pDoc, aNewReq)); + pTabView->SetDrawFuncPtr(new FuSelection(*this, pWin, pView, pDoc, aNewReq)); break; case SID_DRAW_LINE: @@ -226,12 +233,12 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) case SID_DRAW_RECT: case SID_DRAW_ELLIPSE: case SID_DRAW_MEASURELINE: - pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstRectangle>(*this, pWin, pView, pDoc, aNewReq)); + pTabView->SetDrawFuncPtr(new FuConstRectangle(*this, pWin, pView, pDoc, aNewReq)); break; case SID_DRAW_CAPTION: case SID_DRAW_CAPTION_VERTICAL: - pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstRectangle>(*this, pWin, pView, pDoc, aNewReq)); + pTabView->SetDrawFuncPtr(new FuConstRectangle(*this, pWin, pView, pDoc, aNewReq)); pView->SetFrameDragSingles( false ); rBindings.Invalidate( SID_BEZIER_EDIT ); break; @@ -244,25 +251,25 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) case SID_DRAW_BEZIER_FILL: case SID_DRAW_FREELINE: case SID_DRAW_FREELINE_NOFILL: - pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstPolygon>(*this, pWin, pView, pDoc, aNewReq)); + pTabView->SetDrawFuncPtr(new FuConstPolygon(*this, pWin, pView, pDoc, aNewReq)); break; case SID_DRAW_ARC: case SID_DRAW_PIE: case SID_DRAW_CIRCLECUT: - pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstArc>(*this, pWin, pView, pDoc, aNewReq)); + pTabView->SetDrawFuncPtr(new FuConstArc(*this, pWin, pView, pDoc, aNewReq)); break; case SID_DRAW_TEXT: case SID_DRAW_TEXT_VERTICAL: case SID_DRAW_TEXT_MARQUEE: case SID_DRAW_NOTEEDIT: - pTabView->SetDrawFuncPtr(o3tl::make_unique<FuText>(*this, pWin, pView, pDoc, aNewReq)); + pTabView->SetDrawFuncPtr(new FuText(*this, pWin, pView, pDoc, aNewReq)); break; case SID_FM_CREATE_CONTROL: SetDrawFormShell(true); - pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstUnoControl>(*this, pWin, pView, pDoc, aNewReq)); + pTabView->SetDrawFuncPtr(new FuConstUnoControl(*this, pWin, pView, pDoc, aNewReq)); nFormSfxId = nNewFormId; break; @@ -274,7 +281,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) case SID_DRAWTBX_CS_STAR : case SID_DRAW_CS_ID : { - pTabView->SetDrawFuncPtr( o3tl::make_unique<FuConstCustomShape>(*this, pWin, pView, pDoc, aNewReq)); + pTabView->SetDrawFuncPtr(new FuConstCustomShape(*this, pWin, pView, pDoc, aNewReq)); if ( nNewId != SID_DRAW_CS_ID ) { const SfxStringItem* pEnumCommand = rReq.GetArg<SfxStringItem>(nNewId); |