Kaydet (Commit) 5d2f157b authored tarafından Noel Grandin's avatar Noel Grandin

simplify ScChangeTrack queues

no need to store such small struct on the heap

Change-Id: I8d9c12082a40e1d24cf7d25cca7369e1bb034c7a
Reviewed-on: https://gerrit.libreoffice.org/66323
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 9796738e
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <tools/link.hxx> #include <tools/link.hxx>
#include <tools/solar.h> #include <tools/solar.h>
#include <unotools/options.hxx> #include <unotools/options.hxx>
#include <boost/optional.hpp>
#include "global.hxx" #include "global.hxx"
#include "bigrange.hxx" #include "bigrange.hxx"
#include "scdllapi.h" #include "scdllapi.h"
...@@ -799,8 +800,8 @@ struct ScChangeTrackMsgInfo ...@@ -799,8 +800,8 @@ struct ScChangeTrackMsgInfo
}; };
// MsgQueue for notification via ModifiedLink // MsgQueue for notification via ModifiedLink
typedef std::vector<ScChangeTrackMsgInfo*> ScChangeTrackMsgQueue; typedef std::vector<ScChangeTrackMsgInfo> ScChangeTrackMsgQueue;
typedef std::vector<ScChangeTrackMsgInfo*> ScChangeTrackMsgStack; typedef std::vector<ScChangeTrackMsgInfo> ScChangeTrackMsgStack;
typedef std::map<sal_uLong, ScChangeAction*> ScChangeActionMap; typedef std::map<sal_uLong, ScChangeAction*> ScChangeActionMap;
enum ScChangeTrackMergeState enum ScChangeTrackMergeState
...@@ -848,7 +849,7 @@ class ScChangeTrack : public utl::ConfigurationListener ...@@ -848,7 +849,7 @@ class ScChangeTrack : public utl::ConfigurationListener
ScChangeActionLinkEntry* pLinkInsertRow; ScChangeActionLinkEntry* pLinkInsertRow;
ScChangeActionLinkEntry* pLinkInsertTab; ScChangeActionLinkEntry* pLinkInsertTab;
ScChangeActionLinkEntry* pLinkMove; ScChangeActionLinkEntry* pLinkMove;
ScChangeTrackMsgInfo* pBlockModifyMsg; boost::optional<ScChangeTrackMsgInfo> xBlockModifyMsg;
ScDocument* pDoc; ScDocument* pDoc;
sal_uLong nActionMax; sal_uLong nActionMax;
sal_uLong nGeneratedMin; sal_uLong nGeneratedMin;
......
...@@ -2099,7 +2099,7 @@ void ScChangeTrack::Init() ...@@ -2099,7 +2099,7 @@ void ScChangeTrack::Init()
pLinkInsertRow = nullptr; pLinkInsertRow = nullptr;
pLinkInsertTab = nullptr; pLinkInsertTab = nullptr;
pLinkMove = nullptr; pLinkMove = nullptr;
pBlockModifyMsg = nullptr; xBlockModifyMsg.reset();
nActionMax = 0; nActionMax = 0;
nGeneratedMin = SC_CHGTRACK_GENERATED_START; nGeneratedMin = SC_CHGTRACK_GENERATED_START;
nMarkLastSaved = 0; nMarkLastSaved = 0;
...@@ -2148,20 +2148,9 @@ void ScChangeTrack::DtorClear() ...@@ -2148,20 +2148,9 @@ void ScChangeTrack::DtorClear()
void ScChangeTrack::ClearMsgQueue() void ScChangeTrack::ClearMsgQueue()
{ {
if ( pBlockModifyMsg ) xBlockModifyMsg.reset();
{
delete pBlockModifyMsg;
pBlockModifyMsg = nullptr;
}
std::for_each(aMsgStackTmp.rbegin(), aMsgStackTmp.rend(), std::default_delete<ScChangeTrackMsgInfo>());
aMsgStackTmp.clear(); aMsgStackTmp.clear();
std::for_each(aMsgStackFinal.rbegin(), aMsgStackFinal.rend(), std::default_delete<ScChangeTrackMsgInfo>());
aMsgStackFinal.clear(); aMsgStackFinal.clear();
ScChangeTrackMsgQueue::iterator itQueue;
for ( itQueue = aMsgQueue.begin(); itQueue != aMsgQueue.end(); ++itQueue)
delete *itQueue;
aMsgQueue.clear(); aMsgQueue.clear();
} }
...@@ -2262,11 +2251,12 @@ void ScChangeTrack::StartBlockModify( ScChangeTrackMsgType eMsgType, ...@@ -2262,11 +2251,12 @@ void ScChangeTrack::StartBlockModify( ScChangeTrackMsgType eMsgType,
{ {
if ( aModifiedLink.IsSet() ) if ( aModifiedLink.IsSet() )
{ {
if ( pBlockModifyMsg ) if ( xBlockModifyMsg )
aMsgStackTmp.push_back( pBlockModifyMsg ); // Block in Block aMsgStackTmp.push_back( *xBlockModifyMsg ); // Block in Block
pBlockModifyMsg = new ScChangeTrackMsgInfo; xBlockModifyMsg = ScChangeTrackMsgInfo();
pBlockModifyMsg->eMsgType = eMsgType; xBlockModifyMsg->eMsgType = eMsgType;
pBlockModifyMsg->nStartAction = nStartAction; xBlockModifyMsg->nStartAction = nStartAction;
xBlockModifyMsg->nEndAction = 0;
} }
} }
...@@ -2274,25 +2264,25 @@ void ScChangeTrack::EndBlockModify( sal_uLong nEndAction ) ...@@ -2274,25 +2264,25 @@ void ScChangeTrack::EndBlockModify( sal_uLong nEndAction )
{ {
if ( aModifiedLink.IsSet() ) if ( aModifiedLink.IsSet() )
{ {
if ( pBlockModifyMsg ) if ( xBlockModifyMsg )
{ {
if ( pBlockModifyMsg->nStartAction <= nEndAction ) if ( xBlockModifyMsg->nStartAction <= nEndAction )
{ {
pBlockModifyMsg->nEndAction = nEndAction; xBlockModifyMsg->nEndAction = nEndAction;
// Blocks dissolved in Blocks // Blocks dissolved in Blocks
aMsgStackFinal.push_back( pBlockModifyMsg ); aMsgStackFinal.push_back( *xBlockModifyMsg );
} }
else else
delete pBlockModifyMsg; xBlockModifyMsg.reset();
if (aMsgStackTmp.empty()) if (aMsgStackTmp.empty())
pBlockModifyMsg = nullptr; xBlockModifyMsg.reset();
else else
{ {
pBlockModifyMsg = aMsgStackTmp.back(); // Maybe Block in Block xBlockModifyMsg = aMsgStackTmp.back(); // Maybe Block in Block
aMsgStackTmp.pop_back(); aMsgStackTmp.pop_back();
} }
} }
if ( !pBlockModifyMsg ) if ( !xBlockModifyMsg )
{ {
bool bNew = !aMsgStackFinal.empty(); bool bNew = !aMsgStackFinal.empty();
aMsgQueue.reserve(aMsgQueue.size() + aMsgStackFinal.size()); aMsgQueue.reserve(aMsgQueue.size() + aMsgStackFinal.size());
...@@ -2314,7 +2304,7 @@ void ScChangeTrack::NotifyModified( ScChangeTrackMsgType eMsgType, ...@@ -2314,7 +2304,7 @@ void ScChangeTrack::NotifyModified( ScChangeTrackMsgType eMsgType,
{ {
if ( aModifiedLink.IsSet() ) if ( aModifiedLink.IsSet() )
{ {
if ( !pBlockModifyMsg || pBlockModifyMsg->eMsgType != eMsgType || if ( !xBlockModifyMsg || xBlockModifyMsg->eMsgType != eMsgType ||
(IsGenerated( nStartAction ) && (IsGenerated( nStartAction ) &&
(eMsgType == SC_CTM_APPEND || eMsgType == SC_CTM_REMOVE)) ) (eMsgType == SC_CTM_APPEND || eMsgType == SC_CTM_REMOVE)) )
{ // Append within Append e.g. not { // Append within Append e.g. not
......
...@@ -1541,16 +1541,16 @@ IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack&, rChgTrack, void) ...@@ -1541,16 +1541,16 @@ IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack&, rChgTrack, void)
sal_uLong nStartAction; sal_uLong nStartAction;
sal_uLong nEndAction; sal_uLong nEndAction;
for (const auto& pMsg : aMsgQueue) for (const auto& rMsg : aMsgQueue)
{ {
nStartAction = pMsg->nStartAction; nStartAction = rMsg.nStartAction;
nEndAction = pMsg->nEndAction; nEndAction = rMsg.nEndAction;
if(!bIgnoreMsg) if(!bIgnoreMsg)
{ {
bNoSelection=true; bNoSelection=true;
switch(pMsg->eMsgType) switch(rMsg.eMsgType)
{ {
case SC_CTM_APPEND: AppendChanges(&rChgTrack,nStartAction,nEndAction); case SC_CTM_APPEND: AppendChanges(&rChgTrack,nStartAction,nEndAction);
break; break;
...@@ -1560,13 +1560,10 @@ IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack&, rChgTrack, void) ...@@ -1560,13 +1560,10 @@ IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack&, rChgTrack, void)
case SC_CTM_CHANGE: //bNeedsUpdate=true; case SC_CTM_CHANGE: //bNeedsUpdate=true;
UpdateEntrys(&rChgTrack,nStartAction,nEndAction); UpdateEntrys(&rChgTrack,nStartAction,nEndAction);
break; break;
default: default: ;
{
// added to avoid warnings // added to avoid warnings
}
} }
} }
delete pMsg;
} }
aMsgQueue.clear(); aMsgQueue.clear();
......
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