Commit c7ea6292 authored by Michael Pyne's avatar Michael Pyne
Browse files

Backport fix for late access to JuK global static object to KDE 4.1.

svn path=/branches/KDE/4.1/kdemultimedia/juk/; revision=846740
parent 845c53b0
......@@ -257,6 +257,12 @@ CollectionList::~CollectionList()
config.writeEntry("CollectionListSortColumn", sortColumn());
config.writeEntry("CollectionListSortAscending", sortOrder() == Qt::AscendingOrder);
// In some situations the dataChanged signal from clearItems will cause observers to
// subsequently try to access a deleted item. Since we're going away just remove all
// observers.
clearObservers();
// The CollectionListItems will try to remove themselves from the
// m_columnTags member, so we must make sure they're gone before we
// are.
......
......@@ -415,6 +415,12 @@ Playlist::Playlist(PlaylistCollection *collection, bool delaySetup) :
Playlist::~Playlist()
{
// In some situations the dataChanged signal from clearItems will cause observers to
// subsequently try to access a deleted item. Since we're going away just remove all
// observers.
clearObservers();
// clearItem() will take care of removing the items from the history,
// so call clearItems() to make sure it happens.
......
......@@ -40,6 +40,11 @@ void Watched::removeObserver(PlaylistObserver *observer)
m_observers.remove(observer);
}
void Watched::clearObservers()
{
m_observers.clear();
}
Watched::~Watched()
{
foreach(PlaylistObserver *observer, m_observers)
......
......@@ -32,6 +32,12 @@ public:
void addObserver(PlaylistObserver *observer);
void removeObserver(PlaylistObserver *observer);
/**
* Call this to remove all objects observing this class unconditionally (for example, when
* you're being destructed).
*/
void clearObservers();
/**
* This is triggered when the currently playing item has been changed.
*/
......
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