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

List:       kde-commits
Subject:    kdebase/kicker/taskmanager
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2005-04-18 20:07:04
Message-ID: 20050418200704.66C953C8 () office ! kde ! org
[Download RAW message or body]

CVS commit by aseigo: 

use KSharedPtr for the Startup*s that we share everywhere


  M +29 -17    taskmanager.cpp   1.97
  M +12 -9     taskmanager.h   1.64


--- kdebase/kicker/taskmanager/taskmanager.cpp  #1.96:1.97
@@ -325,5 +325,5 @@ void TaskManager::currentDesktopChanged(
 void TaskManager::gotNewStartup( const KStartupInfoId& id, const KStartupInfoData& data )
 {
-    Startup* s = new Startup( id, data, this );
+    Startup::Ptr s = new Startup( id, data, this );
     _startups.append(s);
 
@@ -333,7 +333,10 @@ void TaskManager::gotNewStartup( const K
 void TaskManager::gotStartupChange( const KStartupInfoId& id, const KStartupInfoData& data )
 {
-    for( Startup* s = _startups.first(); s != 0; s = _startups.next()) {
-        if ( s->id() == id ) {
-            s->update( data );
+    StartupList::iterator itEnd = _startups.end();
+    for (StartupList::iterator sIt = _startups.begin(); sIt != itEnd; ++sIt)
+    {
+        if ((*sIt)->id() == id)
+        {
+            (*sIt)->update(data);
             return;
         }
@@ -343,23 +346,33 @@ void TaskManager::gotStartupChange( cons
 void TaskManager::killStartup( const KStartupInfoId& id )
 {
-    Startup* s = 0;
-    for(s = _startups.first(); s != 0; s = _startups.next()) {
-        if (s->id() == id)
+    StartupList::iterator itEnd = _startups.end();
+    Startup::Ptr s = 0;
+    for (StartupList::iterator sIt = _startups.begin(); sIt != itEnd; ++sIt)
+    {
+        if ((*sIt)->id() == id)
+        {
+            s = *sIt;
             break;
     }
-    if (s == 0) return;
+    }
 
-    _startups.removeRef(s);
+    if (!s)
+    {
+        return;
+    }
+
+    _startups.remove(s);
     emit startupRemoved(s);
-    delete s;
 }
 
-void TaskManager::killStartup(Startup* s)
+void TaskManager::killStartup(Startup::Ptr s)
 {
-    if (s == 0) return;
+    if (!s)
+    {
+        return;
+    }
 
-    _startups.removeRef(s);
+    _startups.remove(s);
     emit startupRemoved(s);
-    delete s;
 }
 

--- kdebase/kicker/taskmanager/taskmanager.h  #1.63:1.64
@@ -38,4 +38,5 @@ CONNECTION WITH THE SOFTWARE OR THE USE 
 
 #include <dcopobject.h>
+#include <ksharedptr.h>
 #include <kstartupinfo.h>
 #include <kwin.h>
@@ -462,5 +463,5 @@ public:
  * @see TaskManager
  */
-class KDE_EXPORT Startup: public QObject
+class KDE_EXPORT Startup: public QObject, public KShared
 {
     Q_OBJECT
@@ -470,4 +471,6 @@ class KDE_EXPORT Startup: public QObject
 
 public:
+    typedef KSharedPtr<Startup> Ptr;
+
     Startup( const KStartupInfoId& id, const KStartupInfoData& data, QObject * parent,
         const char *name = 0);
@@ -503,5 +506,6 @@ private:
 };
 
-typedef QPtrList<Startup> StartupList;
+
+typedef QValueList<Startup::Ptr> StartupList;
 
 /**
@@ -541,6 +545,5 @@ public:
 
     /**
-     * Returns a list of all current startups. Return type changed to
-     * QPtrList in KDE 3.
+     * Returns a list of all current startups.
      */
     StartupList startups() const { return _startups; }
@@ -594,5 +597,5 @@ signals:
      * Emitted when a new task is expected.
      */
-    void startupAdded(Startup*);
+    void startupAdded(Startup::Ptr);
 
     /**
@@ -601,5 +604,5 @@ signals:
      * as a result of a timeout.
      */
-    void startupRemoved(Startup*);
+    void startupRemoved(Startup::Ptr);
 
     /**
@@ -629,5 +632,5 @@ protected slots:
     void killStartup( const KStartupInfoId& );
     //* @internal
-    void killStartup(Startup*);
+    void killStartup(Startup::Ptr);
 
     //* @internal


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

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