Kaydet (Commit) f93a2e53 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

reduce branch depth in SwModify dtor

Change-Id: I82046cfc191425dc830125944214293b5b9197f9
üst 0b0d80bd
......@@ -192,7 +192,7 @@ public:
void UnlockModify() { m_bModifyLocked = false; }
void SetInCache( bool bNew ) { m_bInCache = bNew; }
void SetInSwFntCache( bool bNew ) { m_bInSwFntCache = bNew; }
void SetInDocDTOR() { m_bInDocDTOR = true; }
void SetInDocDTOR();
bool IsModifyLocked() const { return m_bModifyLocked; }
bool IsInCache() const { return m_bInCache; }
bool IsInSwFntCache() const { return m_bInSwFntCache; }
......
......@@ -75,6 +75,17 @@ void SwClient::Modify(SfxPoolItem const*const pOldValue, SfxPoolItem const*const
CheckRegistration( pOldValue, pNewValue );
}
void SwModify::SetInDocDTOR()
{
m_bInDocDTOR = true;
// If the document gets destroyed anyway, just tell clients to
// forget me so that they don't try to get removed from my list
// later when they also get destroyed
SwIterator<SwClient,SwModify> aIter(*this);
for(SwClient* pClient = aIter.First(); pClient; pClient = aIter.Next())
pClient->pRegisteredIn = nullptr;
}
SwModify::~SwModify()
{
DBG_TESTSOLARMUTEX();
......@@ -86,20 +97,8 @@ SwModify::~SwModify()
if ( IsInSwFntCache() )
pSwFontCache->Delete( this );
if( m_pWriterListeners )
{
// there are depending objects
if( m_bInDocDTOR )
{
// If the document gets destroyed anyway, just tell clients to
// forget me so that they don't try to get removed from my list
// later when they also get destroyed
SwIterator<SwClient,SwModify> aIter(*this);
for(SwClient* pClient = aIter.First(); pClient; pClient = aIter.Next())
pClient->pRegisteredIn = nullptr;
}
else
{
if(m_bInDocDTOR)
return;
// notify all clients that they shall remove themselves
SwPtrMsgPoolItem aDyObject( RES_OBJECTDYING, this );
NotifyClients( &aDyObject, &aDyObject );
......@@ -108,8 +107,6 @@ SwModify::~SwModify()
// mba: possibly a hotfix for forgotten base class calls?!
while( m_pWriterListeners )
static_cast<SwClient*>(m_pWriterListeners)->CheckRegistration( &aDyObject, &aDyObject );
}
}
}
void SwModify::NotifyClients( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
......
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