Bug 143784

Summary: RSIBreak uses too much pixmap memory while idle
Product: [Applications] rsibreak Reporter: Richard Lärkäng <larkang>
Component: generalAssignee: Tom Albers <toma>
Status: RESOLVED FIXED    
Severity: normal CC: me
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: The patch I used

Description Richard Lärkäng 2007-04-03 14:48:29 UTC
Version:            (using KDE KDE 3.5.6)
Installed from:    Gentoo Packages
OS:                Linux

When running RSIBreak, xrestop shows that it uses around 5 mb of
pixmap memory while RSIBreak is idle here.

This seems to be because m_backgroundimage in RSIWidget is always
the size of the desktop even when it's not needed.

By adding a QWidget::hideEvent to RSIWidget and there clearing m_backgroundimage and the background-image of the widget (and
also not creating a large pixmap when starting the application), xrestop
reports that the pixmap memory usage reduces to around 50 kb instead.
Comment 1 Richard Lärkäng 2007-04-03 14:50:20 UTC
Created attachment 20161 [details]
The patch I used

Here is the patch I applied. It seems to work fine here, but I'm not very
familiar with the code in rsibreak, so I don't know if there are any problems
with it.
Comment 2 Tom Albers 2007-04-03 15:00:41 UTC
Thanks a lot. We will take a look at the patch soon.
Comment 3 Tom Albers 2007-05-27 12:51:35 UTC
SVN commit 668714 by toma:

Keep memory footprint low when idle. Patch by Richard Larkang. Thanks a lot! Feel free to optimise more if you can.
BUG: 143784


 M  +10 -2     rsiwidget.cpp  
 M  +1 -0      rsiwidget.h  


--- trunk/extragear/utils/rsibreak/src/rsiwidget.cpp #668713:668714
@@ -103,8 +103,6 @@
                                  i18n("Welcome"),
                                  "dont_show_welcome_again_for_050");
 
-    m_backgroundimage.resize(QApplication::desktop()->width(),
-                             QApplication::desktop()->height());
     setBackgroundMode( QWidget::NoBackground );
     QRect rect = QApplication::desktop()->screenGeometry(
                         QApplication::desktop()->primaryScreen() );
@@ -605,6 +603,16 @@
     if (e->key() == m_accel->shortcut("minimize"))
         m_timer->skipBreak();
 }
+
+void RSIWidget::hideEvent( QHideEvent * e)
+{
+    kdDebug() << k_funcinfo << endl;
+    m_backgroundimage = QPixmap();
+    setBackgroundPixmap(m_backgroundimage);
+
+    QWidget::hideEvent(e);
+}
+
 //--------------------------- CONFIG ----------------------------//
 
 void RSIWidget::startTimer( bool idle)
--- trunk/extragear/utils/rsibreak/src/rsiwidget.h #668713:668714
@@ -106,6 +106,7 @@
         virtual void mousePressEvent( QMouseEvent * e );
         virtual void mouseReleaseEvent( QMouseEvent * e );
         virtual void keyPressEvent( QKeyEvent * e);
+        virtual void hideEvent( QHideEvent * e);
 
         /** Sets appropriate icon in tooltip and docker. */
         void setIcon( int );