summaryrefslogtreecommitdiffstats
path: root/kmail/isubject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kmail/isubject.cpp')
-rw-r--r--kmail/isubject.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/kmail/isubject.cpp b/kmail/isubject.cpp
index 7219dc0e9..d231d365c 100644
--- a/kmail/isubject.cpp
+++ b/kmail/isubject.cpp
@@ -31,8 +31,15 @@ namespace KMail {
void ISubject::notify()
{
kdDebug(5006) << "ISubject::notify " << mObserverList.size() << endl;
- for ( TQValueVector<Interface::Observer*>::iterator it = mObserverList.begin() ; it != mObserverList.end() ; ++it )
- (*it)->update( this );
+
+ // iterate over a copy (to prevent crashes when
+ // {attach(),detach()} is called from an Observer::update()
+ const TQValueVector<Interface::Observer*> copy = mObserverList;
+ for ( TQValueVector<Interface::Observer*>::const_iterator it = copy.begin() ; it != copy.end() ; ++it ) {
+ if ( (*it) ) {
+ (*it)->update( this );
+ }
+ }
}
}