patch: kclipboard

Simon Hausmann hausmann at kde.org
Fri Oct 25 08:44:24 BST 2002


Hi,

The patch is self-explaning :)

Simon
-------------- next part --------------
Index: kclipboard.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kclipboard.cpp,v
retrieving revision 1.33
diff -u -p -b -r1.33 kclipboard.cpp
--- kclipboard.cpp	2002/10/24 22:23:44	1.33
+++ kclipboard.cpp	2002/10/25 07:40:01
@@ -19,6 +19,7 @@
 #include <kapplication.h>
 #include <kconfig.h>
 #include <kglobal.h>
+#include <kstaticdeleter.h>
 
 #include "kclipboard.h"
 
@@ -81,6 +82,7 @@ private:
 
 
 KClipboard * KClipboard::s_self = 0L;
+namespace { KStaticDeleter< KClipboard > clipboardsd; }
 bool KClipboard::s_sync = false;
 bool KClipboard::s_implicitSelection = true;
 bool KClipboard::s_blocked = false;
@@ -88,7 +90,7 @@ bool KClipboard::s_blocked = false;
 KClipboard * KClipboard::self()
 {
     if ( !s_self )
-        s_self = new KClipboard( kapp, "KDE Clipboard" );
+        clipboardsd.setObject( s_self, new KClipboard( kapp, "KDE Clipboard" ) );
 
     return s_self;
 }
@@ -112,8 +114,6 @@ KClipboard::KClipboard( QObject *parent,
 
 KClipboard::~KClipboard()
 {
-    if ( s_self == this )
-        s_self = 0L;
 }
 
 void KClipboard::slotSelectionChanged()
Index: kclipboard.h
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kclipboard.h,v
retrieving revision 1.20
diff -u -p -b -r1.20 kclipboard.h
--- kclipboard.h	2002/10/24 22:23:44	1.20
+++ kclipboard.h	2002/10/25 07:40:01
@@ -24,6 +24,8 @@
 #include <qobject.h>
 #include <qstrlist.h>
 
+template < class > class KStaticDeleter;
+
 /**
  * This class is mostly of internal use. You probably don't need it :)
  *
@@ -49,6 +51,7 @@ class KClipboard : public QObject
 public:
     friend class KlipperWidget;
     friend class KApplication;
+    friend class KStaticDeleter< KClipboard >;
 
     /**
      * Returns the KClipboard singleton object.


More information about the kde-core-devel mailing list