~neon/juk/master

« back to all changes in this revision

Viewing changes to collectionlist.cpp

  • Committer: Michael Pyne
  • Date: 2009-02-16 03:58:42 UTC
  • Revision ID: git-v1:2e8654643da748da327a6f8859529314f240f238
Last crasher bug I fixed was due to not using Playlist::clearItem() to remove a PlaylistItem.  I think it
should always be possible to call delete on a PlaylistItem pointer and the Right Thing happens, so do a
bit of refactoring to ensure that what happens in clearItem() is performed from the PlaylistItem dtor instead
of running the PlaylistItem dtor from clearItem.

svn path=/trunk/KDE/kdemultimedia/juk/; revision=926748

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
 
129
129
void CollectionList::clearItems(const PlaylistItemList &items)
130
130
{
131
 
    for(PlaylistItemList::ConstIterator it = items.constBegin(); it != items.constEnd(); ++it) {
132
 
        Cache::instance()->remove((*it)->file());
133
 
        clearItem(*it, false);
 
131
    foreach(PlaylistItem *item, items) {
 
132
        Cache::instance()->remove(item->file());
 
133
        delete item;
134
134
    }
135
135
 
136
136
    dataChanged();
178
178
            if(item->file().fileInfo().exists())
179
179
                item->repaint();
180
180
            else
181
 
                clearItem(item);
 
181
                delete item;
182
182
        }
183
183
    }
184
184
 
187
187
 
188
188
void CollectionList::slotDeleteItem(const KFileItem &item)
189
189
{
190
 
    CollectionListItem *listItem = lookup(item.url().path());
191
 
    if(listItem)
192
 
        clearItem(listItem);
 
190
    delete lookup(item.url().path());
193
191
}
194
192
 
195
193
////////////////////////////////////////////////////////////////////////////////
232
230
 
233
231
void CollectionList::slotRemoveItem(const QString &file)
234
232
{
235
 
    clearItem(m_itemsDict[file]);
 
233
    delete m_itemsDict[file];
236
234
}
237
235
 
238
236
void CollectionList::slotRefreshItem(const QString &file)
492
490
{
493
491
    m_shuttingDown = true;
494
492
 
495
 
    foreach(PlaylistItem *item, m_children) {
496
 
        if(item->playlist())
497
 
            item->playlist()->clearItem(item);
498
 
    }
 
493
    foreach(PlaylistItem *item, m_children)
 
494
        delete item;
499
495
 
500
496
    CollectionList *l = CollectionList::instance();
501
497
    if(l) {