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

List:       kde-commits
Subject:    kdelibs/kstyles/keramik
From:       Maks Orlovich <maksim () kde ! org>
Date:       2003-12-07 23:50:07
[Download RAW message or body]

CVS commit by orlovich: 

Do not leak animation timers when we're switched out of.
Reviewed by Fredrik Höglund


  M +19 -5     keramik.cpp   1.120
  M +8 -4      keramik.h   1.24


--- kdelibs/kstyles/keramik/keramik.cpp  #1.119:1.120
@@ -302,4 +302,9 @@ void KeramikStyle::updateProgressPos()
         if (progAnimShift == 28)
                 progAnimShift = 0;
+                
+        //Update the registered progressbars.
+        QMap<QWidget*, bool>::iterator iter;
+        for (iter = progAnimWidgets.begin(); iter != progAnimWidgets.end(); iter++)
+                iter.key()->update();
 }
 
@@ -346,9 +351,8 @@ void KeramikStyle::polish(QWidget* widge
         }
 
-        if (animateProgressBar && widget->inherits("QProgressBar"))
+        if (animateProgressBar && ::qt_cast<QProgressBar*>(widget))
         {
-                QTimer* timer = new QTimer(widget);
-                timer->start(50);
-                connect(timer, SIGNAL(timeout()), widget, SLOT(update()));
+                progAnimWidgets[widget] = true;
+                connect(widget, SIGNAL(destroyed(QObject*)), this, \
SLOT(progressBarDestroyed(QObject*)));  }
 
@@ -358,4 +362,5 @@ void KeramikStyle::polish(QWidget* widge
 void KeramikStyle::unPolish(QWidget* widget)
 {
+        //### TODO: This needs major cleanup (and so does polish() )
         if ( widget->inherits( "QPushButton" ) || widget->inherits( "QComboBox"  ) )
         {
@@ -382,6 +387,15 @@ void KeramikStyle::unPolish(QWidget* wid
                 widget->removeEventFilter(this);
         }
+        else if ( ::qt_cast<QProgressBar*>(widget) )
+        {
+                progAnimWidgets.remove(widget);
+        }
 
         KStyle::unPolish(widget);
+}
+
+void KeramikStyle::progressBarDestroyed(QObject* obj)
+{
+        progAnimWidgets.remove(static_cast<QWidget*>(obj));
 }
 

--- kdelibs/kstyles/keramik/keramik.h  #1.23:1.24
@@ -116,6 +116,8 @@ public:
                                       const QStyleOption& opt = \
QStyleOption::Default ) const;  
-public slots:
+private slots:
+        //Animation slots.
         void updateProgressPos();
+        void progressBarDestroyed(QObject* bar);
 
 private:
@@ -135,6 +138,4 @@ private:
         mutable const QWidget* toolbarBlendWidget;  //Ditto for blending with \
toolbars  
-        int                        progAnimShift;
-
         enum TitleBarMode
         {
@@ -153,4 +154,7 @@ private:
         mutable bool customScrollMode; //Set when drawing scrollbars with custom \
colors.  
+        //Animation support.
+        QMap<QWidget*, bool> progAnimWidgets;
+        int                  progAnimShift;
 
         bool eventFilter( QObject* object, QEvent* event );


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

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