From kde-core-devel Mon Nov 22 17:42:58 2004 From: Waldo Bastian Date: Mon, 22 Nov 2004 17:42:58 +0000 To: kde-core-devel Subject: CPU Usage Plastik&Keramik style Message-Id: <200411221842.58526.bastian () suse ! com> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=110114535623265 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_iUioBMKvSL2kT0R" --Boundary-00=_iUioBMKvSL2kT0R Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 --Boundary-00=_iUioBMKvSL2kT0R Content-Type: text/x-diff; charset="us-ascii"; name="plastik.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="plastik.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(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(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 *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 --Boundary-00=_iUioBMKvSL2kT0R--