[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    CPU Usage Plastik&Keramik style
From:       Waldo Bastian <bastian () suse ! com>
Date:       2004-11-22 17:42:58
Message-ID: 200411221842.58526.bastian () suse ! com
[Download RAW message or body]

The Plastik&Keramik styles have a performance issue. When progress bar 
animation is enabled it fires a timer 20 times per second. This would be 
acceptable if it does that when showing a progressbar, but the problem is 
that this timer runs all of the time, for each and every application. The 
problem is that this causes otherwise idle processes to be scheduled in all 
the time.

I have made a patch to only start the timer when there is actually a progress 
bar around. That improves the situation a lot already, but it seems that 
konqueror always keeps a progressbar around (the one in KonqFrameStatusBar), 
even though it isn't shown most of the time. Any ideas how to solve that?

Cheers,
Waldo
-- 
bastian@kde.org   |   Free Novell Linux Desktop 9 Evaluation Download
bastian@suse.com  |   http://www.novell.com/products/desktop/eval.html

["plastik.diff" (text/x-diff)]

Index: plastik.cpp
===================================================================
RCS file: /home/kde/kdelibs/kstyles/plastik/plastik.cpp,v
retrieving revision 1.103
diff -u -p -r1.103 plastik.cpp
--- plastik.cpp	17 Nov 2004 15:17:21 -0000	1.103
+++ plastik.cpp	22 Nov 2004 17:15:04 -0000
@@ -186,9 +186,8 @@ PlastikStyle::PlastikStyle() : KStyle( A
 
     if ( _animateProgressBar )
     {
-        QTimer* timer = new QTimer( this );
-        timer->start( 50, false );
-        connect( timer, SIGNAL(timeout()), this, SLOT(updateProgressPos()) );
+        animationTimer = new QTimer( this );
+        connect( animationTimer, SIGNAL(timeout()), this, SLOT(updateProgressPos()) );
     }
 }
 
@@ -263,6 +262,8 @@ void PlastikStyle::polish(QWidget* widge
     {
         progAnimWidgets[widget] = 0;
         connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(progressBarDestroyed(QObject*)));
+        if (!animationTimer->isActive())
+            animationTimer->start( 50, false );
     }
 
     KStyle::polish(widget);
@@ -295,6 +296,8 @@ void PlastikStyle::unPolish(QWidget* wid
     if ( ::qt_cast<QProgressBar*>(widget) )
     {
         progAnimWidgets.remove(widget);
+        if (progAnimWidgets.count() == 0)
+            animationTimer->stop();
     }
 
     KStyle::unPolish(widget);
@@ -308,6 +311,8 @@ void PlastikStyle::khtmlWidgetDestroyed(
 void PlastikStyle::progressBarDestroyed(QObject* obj)
 {
     progAnimWidgets.remove(static_cast<QWidget*>(obj));
+    if (progAnimWidgets.count() == 0)
+        animationTimer->stop();
 }
 
 void PlastikStyle::renderContour(QPainter *p,
Index: plastik.h
===================================================================
RCS file: /home/kde/kdelibs/kstyles/plastik/plastik.h,v
retrieving revision 1.33
diff -u -p -r1.33 plastik.h
--- plastik.h	13 Nov 2004 00:13:44 -0000	1.33
+++ plastik.h	22 Nov 2004 17:15:05 -0000
@@ -52,6 +52,7 @@
 
 class QSettings;
 class QTab;
+class QTimer;
 
 class PlastikStyle : public KStyle
 {
@@ -356,7 +357,7 @@ private:
         }
     };
     QIntCache<CacheEntry> *pixmapCache;
-
+    
     // For renderFocusRect
     mutable QBitmap *verticalDots;
     mutable QBitmap *horizontalDots;
@@ -364,6 +365,9 @@ private:
     // For KPE_ListViewBranch
     mutable QBitmap *verticalLine;
     mutable QBitmap *horizontalLine;
+    
+    // For progress bar animation
+    QTimer *animationTimer;
 };
 
 #endif // __PLASTIK_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic