┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-03-23 02:46:52 +0000
committerPeter Penz <[email protected]>2008-03-23 02:46:52 +0000
commit4d80f9924ac0c327d33170f9db3110f32a3c2607 (patch)
tree1083afe400146f3d0cf226e5c80f5119a0120671
parent8c6e717eadc966196f72b7552012c12f46c720ce (diff)
take care to restart the timer even when no previews are in the queue: as long as preview jobs are working, new previews will arrive
svn path=/trunk/KDE/kdebase/apps/; revision=789066
-rw-r--r--src/iconmanager.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/iconmanager.cpp b/src/iconmanager.cpp
index cde15b00b..fb522fd99 100644
--- a/src/iconmanager.cpp
+++ b/src/iconmanager.cpp
@@ -135,32 +135,35 @@ void IconManager::updateCutItems()
void IconManager::dispatchPreviewQueue()
{
- const int previewsCount = m_previews.count();
- if (previewsCount == 0) {
- return;
- }
+ int previewsCount = m_previews.count();
+ if (previewsCount > 0) {
+ // Applying the previews to the model must be done step by step
+ // in larger blocks: Applying a preview immediately when getting the signal
+ // 'gotPreview()' from the PreviewJob is too expensive, as a relayout
+ // of the view would be triggered for each single preview.
- // Applying the previews to the model must be done step by step
- // in larger blocks: Applying a preview immediately when getting the signal
- // 'gotPreview()' from the PreviewJob is too expensive, as a relayout
- // of the view would be triggered for each single preview.
+ int dispatchCount = 30;
+ if (dispatchCount > m_previews.count()) {
+ dispatchCount = m_previews.count();
+ }
- int dispatchCount = 30;
- if (dispatchCount > previewsCount) {
- dispatchCount = previewsCount;
- }
+ for (int i = 0; i < dispatchCount; ++i) {
+ const Preview& preview = m_previews.first();
+ replaceIcon(preview.item, preview.pixmap);
+ m_previews.pop_front();
+ }
- for (int i = 0; i < dispatchCount; ++i) {
- const Preview& preview = m_previews.first();
- replaceIcon(preview.item, preview.pixmap);
- m_previews.pop_front();
+ previewsCount = m_previews.count();
}
- if (m_previews.count() > 0) {
- // there are still pending previews; if no preview job is
- // working, poll more aggressively:
- const int timeout = (m_previewJobs.count() > 0) ? 200 : 10;
- m_previewTimer->start(timeout);
+ const bool workingPreviewJobs = (m_previewJobs.count() > 0);
+ if (workingPreviewJobs) {
+ // poll for previews as long as not all preview jobs are finished
+ m_previewTimer->start(200);
+ } else if (previewsCount > 0) {
+ // all preview jobs are finished but there are still pending previews
+ // in the queue -> poll more aggressively
+ m_previewTimer->start(10);
}
}