Kaydet (Commit) af8d2b51 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Revert "loplugin:useuniqueptr in SwGrammarContact"

This reverts commit 478d967e.

Sadly the change caused a crash in Writer. Stack trace:

> #0  0x00007fffc8b124cc in rtl::OUString::isEmpty() const (this=0x6666000000000000) at /ssd1/lo/fedora/include/rtl/ustring.hxx:646
> #1  0x00007fffc95ccaa8 in SwWrongList::GetWrongPos(int) const (this=0x5bb5f60, nValue=0)
>     at /ssd1/lo/fedora/sw/source/core/text/wrong.cxx:199
> #2  0x00007fffc95cd0d2 in SwWrongList::Move(int, int) (this=0x5bb5f60, nPos=0, nDiff=1)
>     at /ssd1/lo/fedora/sw/source/core/text/wrong.cxx:274
> #3  0x00007fffc94caffd in SwGrammarMarkUp::MoveGrammar(int, int) (this=0x5bb5f60, nPos=0, nDiff=1)
>     at /ssd1/lo/fedora/sw/source/core/text/SwGrammarMarkUp.cxx:41
> #4  0x00007fffc95af393 in lcl_SetWrong(SwTextFrame&, SwTextNode const&, int, int, bool) (rFrame=..., rNode=..., nPos=0, nCnt=1, bMove=true)
>     at /ssd1/lo/fedora/sw/source/core/text/txtfrm.cxx:1462
> #5  0x00007fffc95ad0ba in SwTextFrame::SwClientNotify(SwModify const&, SfxHint const&) (this=0x62f3c50, rModify=..., rHint=...)
>     at /ssd1/lo/fedora/sw/source/core/text/txtfrm.cxx:1676
> #6  0x00007fffc8bd96b8 in SwModify::CallSwClientNotify(SfxHint const&) const (this=0x4cef450, rHint=...)
>     at /ssd1/lo/fedora/sw/inc/calbck.hxx:444
> #7  0x00007fffc8bd893e in SwModify::ModifyBroadcast(SfxPoolItem const*, SfxPoolItem const*) (this=0x4cef450,
>     pOldValue=0x0, pNewValue=0x7ffffffed3a8) at /ssd1/lo/fedora/sw/inc/calbck.hxx:201
> #8  0x00007fffc8bd65d1 in SwModify::NotifyClients(SfxPoolItem const*, SfxPoolItem const*) (this=0x4cef450, pOldValue=0x0, pNewValue=0x7ffffffed3a8) at /ssd1/lo/fedora/sw/source/core/attr/calbck.cxx:199
> #9  0x00007fffc965ec9f in SwTextNode::InsertText(rtl::OUString const&, SwIndex const&, SwInsertFlags) (this=0x4cef450, rStr="s", rIdx=SwIndex (offset 1), nMode=SwInsertFlags::EMPTYEXPAND) at /ssd1/lo/fedora/sw/source/core/txtnode/ndtxt.cxx:1997
> #10 0x00007fffc8ef97be in sw::DocumentContentOperationsManager::InsertString(SwPaM const&, rtl::OUString const&, SwInsertFlags) (this=0x4ca2ef0, rRg=SwPaM = {...}, rStr="s", nInsertMode=SwInsertFlags::EMPTYEXPAND)
>     at /ssd1/lo/fedora/sw/source/core/doc/DocumentContentOperationsManager.cxx:2509
> #11 0x00007fffc919bf7b in SwEditShell::Insert2(rtl::OUString const&, bool) (this=0x4d8eb90, rStr="s", bForceExpandHints=false)
>     at /ssd1/lo/fedora/sw/source/core/edit/editsh.cxx:98
> #12 0x00007fffca1d0cca in SwWrtShell::Insert(rtl::OUString const&) (this=0x4d8eb90, rStr="s")
>     at /ssd1/lo/fedora/sw/source/uibase/wrtsh/wrtsh1.cxx:224
> #13 0x00007fffc9e71220 in SwEditWin::FlushInBuffer() (this=0x4d7a3e0) at /ssd1/lo/fedora/sw/source/uibase/docvw/edtwin.cxx:989
> #14 0x00007fffc9e7accc in SwEditWin::KeyInput(KeyEvent const&) (this=0x4d7a3e0, rKEvt=...)
>     at /ssd1/lo/fedora/sw/source/uibase/docvw/edtwin.cxx:2620

Noel said I should revert and push.

Change-Id: I22d51bb3b5427af261cd4a1af19f9fa378891d27
üst 3eeb603c
......@@ -41,7 +41,7 @@ public:
SwGrammarMarkUp() : SwWrongList( WRONGLIST_GRAMMAR ) {}
virtual ~SwGrammarMarkUp() override;
virtual std::unique_ptr<SwWrongList> Clone() override;
virtual SwWrongList* Clone() override;
virtual void CopyFrom( const SwWrongList& rCopy ) override;
/* SwWrongList::Move() + handling of maSentence */
......
......@@ -259,7 +259,7 @@ public:
SwWrongList( WrongListType eType );
virtual ~SwWrongList();
virtual std::unique_ptr<SwWrongList> Clone();
virtual SwWrongList* Clone();
virtual void CopyFrom( const SwWrongList& rCopy );
WrongListType GetWrongListType() const { return meType; }
......
......@@ -23,9 +23,9 @@ SwGrammarMarkUp::~SwGrammarMarkUp()
{
}
std::unique_ptr<SwWrongList> SwGrammarMarkUp::Clone()
SwWrongList* SwGrammarMarkUp::Clone()
{
std::unique_ptr<SwWrongList> pClone(new SwGrammarMarkUp());
SwWrongList* pClone = new SwGrammarMarkUp();
pClone->CopyFrom( *this );
return pClone;
}
......
......@@ -62,9 +62,9 @@ SwWrongList::~SwWrongList()
ClearList();
}
std::unique_ptr<SwWrongList> SwWrongList::Clone()
SwWrongList* SwWrongList::Clone()
{
std::unique_ptr<SwWrongList> pClone(new SwWrongList( meType ));
SwWrongList* pClone = new SwWrongList( meType );
pClone->CopyFrom( *this );
return pClone;
}
......@@ -78,7 +78,7 @@ void SwWrongList::CopyFrom( const SwWrongList& rCopy )
for(SwWrongArea & i : maList)
{
if( i.mpSubList )
i.mpSubList = i.mpSubList->Clone().release();
i.mpSubList = i.mpSubList->Clone();
}
}
......
......@@ -41,14 +41,14 @@
class SwGrammarContact : public IGrammarContact, public SwClient
{
Timer aTimer;
std::unique_ptr<SwGrammarMarkUp> mpProxyList;
SwGrammarMarkUp *mpProxyList;
bool mbFinished;
SwTextNode* getMyTextNode() { return static_cast<SwTextNode*>(GetRegisteredIn()); }
DECL_LINK( TimerRepaint, Timer *, void );
public:
SwGrammarContact();
virtual ~SwGrammarContact() override { aTimer.Stop(); }
virtual ~SwGrammarContact() override { aTimer.Stop(); delete mpProxyList; }
// (pure) virtual functions of IGrammarContact
virtual void updateCursorPosition( const SwPosition& rNewPos ) override;
......@@ -73,7 +73,7 @@ IMPL_LINK( SwGrammarContact, TimerRepaint, Timer *, pTimer, void )
pTimer->Stop();
if( GetRegisteredIn() )
{ //Replace the old wrong list by the proxy list and repaint all frames
getMyTextNode()->SetGrammarCheck( mpProxyList.get() );
getMyTextNode()->SetGrammarCheck( mpProxyList );
mpProxyList = nullptr;
SwTextFrame::repaintTextFrames( *getMyTextNode() );
}
......@@ -91,7 +91,7 @@ void SwGrammarContact::updateCursorPosition( const SwPosition& rNewPos )
{
if( mpProxyList )
{ // replace old list by the proxy list and repaint
getMyTextNode()->SetGrammarCheck( mpProxyList.get() );
getMyTextNode()->SetGrammarCheck( mpProxyList );
SwTextFrame::repaintTextFrames( *getMyTextNode() );
}
EndListeningAll();
......@@ -112,21 +112,22 @@ SwGrammarMarkUp* SwGrammarContact::getGrammarCheck( SwTextNode& rTextNode, bool
{
if( mbFinished )
{
mpProxyList.reset();
delete mpProxyList;
mpProxyList = nullptr;
}
if( !mpProxyList )
{
if( rTextNode.GetGrammarCheck() )
mpProxyList.reset( static_cast<SwGrammarMarkUp*>(rTextNode.GetGrammarCheck()->Clone().release()) );
mpProxyList = static_cast<SwGrammarMarkUp*>(rTextNode.GetGrammarCheck()->Clone());
else
{
mpProxyList.reset( new SwGrammarMarkUp() );
mpProxyList = new SwGrammarMarkUp();
mpProxyList->SetInvalid( 0, COMPLETE_STRING );
}
}
mbFinished = false;
}
pRet = mpProxyList.get();
pRet = mpProxyList;
}
else
{
......@@ -152,7 +153,8 @@ void SwGrammarContact::Modify( const SfxPoolItem* pOld, const SfxPoolItem * )
{ // if my current paragraph dies, I throw the proxy list away
aTimer.Stop();
EndListeningAll();
mpProxyList.reset();
delete mpProxyList;
mpProxyList = nullptr;
}
}
......
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