]> cloud.milkyroute.net Git - dolphin.git/commitdiff
take care to restart the timer even when no previews are in the queue: as long as...
authorPeter Penz <peter.penz19@gmail.com>
Sun, 23 Mar 2008 02:46:52 +0000 (02:46 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 23 Mar 2008 02:46:52 +0000 (02:46 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=789066

src/iconmanager.cpp

index cde15b00b01757785fcdba1e4a3d91e00726725f..fb522fd99a48467fbf5df1cd5ce1d8429e963db2 100644 (file)
@@ -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);
     }
 }