From: Peter Penz Date: Sun, 23 Mar 2008 02:46:52 +0000 (+0000) Subject: take care to restart the timer even when no previews are in the queue: as long as... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/4d80f9924ac0c327d33170f9db3110f32a3c2607?ds=inline 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 --- 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; - } - - // 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 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. + + 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); } }