Fix possible memory leak when invoking KLoadMetaDataThread::cancelAndDelete().

svn path=/trunk/KDE/kdebase/apps/; revision=1097154
This commit is contained in:
Peter Penz 2010-02-28 15:01:33 +00:00
parent 77d9413d07
commit 072dacbb55
2 changed files with 12 additions and 5 deletions

View file

@ -55,11 +55,16 @@ void KLoadMetaDataThread::load(const KUrl::List& urls)
void KLoadMetaDataThread::cancelAndDelete()
{
if (isFinished()) {
Q_ASSERT(!isRunning());
deleteLater();
} else {
connect(this, SIGNAL(finished()), this, SLOT(slotFinished()));
m_canceled = true;
// Setting m_canceled to true will cancel KLoadMetaDataThread::run()
// as soon as possible. Afterwards the thread will delete itself
// asynchronously inside slotFinished().
}
}
void KLoadMetaDataThread::run()

View file

@ -436,6 +436,8 @@ void KMetaDataWidget::Private::slotLoadingFinished()
m_files = m_loadMetaDataThread->files();
Q_ASSERT(!m_loadMetaDataThread->isRunning());
Q_ASSERT(m_loadMetaDataThread->isFinished());
m_loadMetaDataThread->deleteLater();
m_loadMetaDataThread = 0;
#endif