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