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

List:       kde-core-devel
Subject:    Patch for kstartupinfo
From:       David Faure <david () mandrakesoft ! com>
Date:       2001-06-01 10:32:21
[Download RAW message or body]

I found that there is a 1-second timer running all the time in kdesktop (at least)
due to KStartupInfo.
Am I right that storing a pointer all the time is better than having a useless timer
be triggered every second (in every app using that class - not sure how many that is) ?

Since we append to d->startups at only one place, this is quite easy to do :

Index: kstartupinfo.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kstartupinfo.cpp,v
retrieving revision 1.6
diff -u -p -r1.6 kstartupinfo.cpp
--- kstartupinfo.cpp    2001/05/30 22:19:50     1.6
+++ kstartupinfo.cpp    2001/06/01 11:28:28
@@ -75,6 +75,7 @@ struct KStartupInfoPrivate
         QMap< KStartupInfoId, KStartupInfo::Data > startups;
         KWinModule* wm_module;
         KXMessages msgs;
+       QTimer* cleanup;
        KStartupInfoPrivate() : msgs( KDE_STARTUP_INFO ) {}
     };

@@ -87,9 +88,8 @@ KStartupInfo::KStartupInfo( bool clean_o
     connect( d->wm_module, SIGNAL( windowAdded( WId )), SLOT( window_added( WId )));
     connect( d->wm_module, SIGNAL( systemTrayWindowAdded( WId )), SLOT( window_added( WId )));
     connect( &d->msgs, SIGNAL( gotMessage( const QString& )), SLOT( got_message( const QString& )));
-    QTimer* cleanup = new QTimer( this );
-    connect( cleanup, SIGNAL( timeout()), SLOT( startups_cleanup()));
-    cleanup->start( 1000 ); // 1 sec
+    d->cleanup = new QTimer( this );
+    connect( d->cleanup, SIGNAL( timeout()), SLOT( startups_cleanup()));
     }

 KStartupInfo::~KStartupInfo()
@@ -150,6 +150,7 @@ void KStartupInfo::new_startup_info_inte
     d->startups.insert( id_P, data_P );
     kdDebug( 172 ) << "adding" << endl;
     emit gotNewStartup( id_P, data_P );
+    d->cleanup->start( 1000 ); // 1 sec
     }
 
 void KStartupInfo::got_remove_startup_info( const QString& msg_P )
@@ -451,7 +452,10 @@ void KStartupInfo::startups_cleanup_no_a
 void KStartupInfo::startups_cleanup()
     {
     if( d->startups.count() == 0 )
+    {
+        d->cleanup->stop();
         return;
+    }
     startups_cleanup_internal( true );
     }

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://perso.mandrakesoft.com/~david/, http://www.konqueror.org/
KDE, Making The Future of Computing Available Today

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

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