From 55678afcc17fe987cb67588e34cff807dd64ad5d Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Tue, 21 Jan 2014 19:07:58 +0100 Subject: Use only one "directory contents counting" thread per process The pointer to QThread object is stored in a global variable, and each view increments/decrements a reference count when it starts/stops using the thread. If this thread reaches zero, the thread is stopped. Note that we cannot just use a smart pointer, like QSharedPointer, to manage the thread, because we must make sure that the thread is not running any more before the QThread is deleted. REVIEW: 115064 --- src/kitemviews/private/kdirectorycontentscounter.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/kitemviews/private/kdirectorycontentscounter.h') diff --git a/src/kitemviews/private/kdirectorycontentscounter.h b/src/kitemviews/private/kdirectorycontentscounter.h index 425c3632a..c03d0249c 100644 --- a/src/kitemviews/private/kdirectorycontentscounter.h +++ b/src/kitemviews/private/kdirectorycontentscounter.h @@ -78,7 +78,9 @@ private: QQueue m_queue; - QThread* m_workerThread; + static QThread* m_workerThread; + static int m_workersCount; + KDirectoryContentsCounterWorker* m_worker; bool m_workerIsBusy; -- cgit v1.3.1