diff options
| author | Fat-Zer <fatzer2@gmail.com> | 2025-08-12 06:41:18 +0000 |
|---|---|---|
| committer | Alexander Golubev <fatzer2@gmail.com> | 2025-08-21 12:56:37 +0300 |
| commit | b8c11599eae152e7caebf81a1513747f697983fd (patch) | |
| tree | c7ac6b3c4dd3461a71da50fc47ffba54e8ed3bca | |
| parent | 4c559eaf969fd33b056570ca97551b9a75380416 (diff) | |
| download | amarok-b8c11599.tar.gz amarok-b8c11599.zip | |
Fix crash on collection rescan
Closes: https://mirror.git.trinitydesktop.org/gitea/TDE/amarok/issues/87
Signed-off-by: Fat-Zer <fatzer2@gmail.com>
(cherry picked from commit 93a44a17e4fc020f34eaa8b3064711f591026650)
| -rw-r--r-- | amarok/src/playlist.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/amarok/src/playlist.cpp b/amarok/src/playlist.cpp index 6e675338..43f95dc6 100644 --- a/amarok/src/playlist.cpp +++ b/amarok/src/playlist.cpp @@ -922,12 +922,15 @@ Playlist::updateEntriesStatusAdded( const TQMap<TQString,TQString> &map ) TQMap<TQString,TQPtrList<PlaylistItem>*> uniquecopy( m_uniqueMap ); TQMap<TQString,TQPtrList<PlaylistItem>*>::Iterator it; - for( it = uniquecopy.begin(); it != uniquecopy.end(); ++it ) + for( it = uniquecopy.begin(); it != uniquecopy.end(); ) { - if( map.contains( it.key() )) + // remove() may invalidate the iterator, so make a copy and increment + // it before modifying the collection + TQMap<TQString,TQPtrList<PlaylistItem>*>::Iterator cur = it++; + if( map.contains( cur.key() )) { - updateEntriesStatusAdded( map[it.key()], it.key() ); - uniquecopy.remove( it ); + updateEntriesStatusAdded( map[cur.key()], cur.key() ); + uniquecopy.remove( cur ); } } |
