diff options
| author | Frank Reininghaus <[email protected]> | 2014-04-29 21:44:46 +0200 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2014-04-29 21:44:46 +0200 |
| commit | eddb62ac0c9cf2c37991401ea5332a7f334c05a9 (patch) | |
| tree | d22b2e9c05d3fe8be3d8ba62d7e46ca5fa7ab380 /src/kitemviews/private | |
| parent | ae5bcfcdeece23915e7272af1046a7e71e269474 (diff) | |
| parent | 5f29eec07572503679ca1dd354236065f33ff4a7 (diff) | |
Merge branch 'KDE/4.13'
Diffstat (limited to 'src/kitemviews/private')
| -rw-r--r-- | src/kitemviews/private/kdirectorycontentscounter.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/kitemviews/private/kdirectorycontentscounter.cpp b/src/kitemviews/private/kdirectorycontentscounter.cpp index 65afb7c3e..7d1e76999 100644 --- a/src/kitemviews/private/kdirectorycontentscounter.cpp +++ b/src/kitemviews/private/kdirectorycontentscounter.cpp @@ -60,14 +60,23 @@ KDirectoryContentsCounter::~KDirectoryContentsCounter() { --m_workersCount; - if (m_workersCount == 0) { + if (m_workersCount > 0) { + // The worker thread will continue running. It could even be running + // a method of m_worker at the moment, so we delete it using + // deleteLater() to prevent a crash. + m_worker->deleteLater(); + } else { + // There are no remaining workers -> stop the worker thread. m_workerThread->quit(); m_workerThread->wait(); delete m_workerThread; m_workerThread = 0; - } - delete m_worker; + // The worker thread has finished running now, so it's safe to delete + // m_worker. deleteLater() would not work at all because the event loop + // which would deliver the event to m_worker is not running any more. + delete m_worker; + } } void KDirectoryContentsCounter::addDirectory(const QString& path) |
