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

List:       kde-commits
Subject:    branches/KDE/3.5/kdelibs/kio/kio
From:       Andreas Kling <kling () impul ! se>
Date:       2006-09-17 16:58:19
Message-ID: 1158512299.763795.25598.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 585660 by kling:

Fixed memory leak when modifying KURIFilterData objects via operator= or setData()

Had to be done in a slightly uncomfortable way, since it's partly inline code
and the constructors don't initialize `d'.


 M  +12 -0     kurifilter.cpp  
 M  +10 -4     kurifilter.h  


--- branches/KDE/3.5/kdelibs/kio/kio/kurifilter.cpp #585659:585660
@@ -101,6 +101,18 @@
     d->typedString = url;
 }
 
+void KURIFilterData::reinit(const KURL &url)
+{
+    delete d;
+    init(url);
+}
+
+void KURIFilterData::reinit(const QString &url)
+{
+    delete d;
+    init(url);
+}
+
 QString KURIFilterData::typedString() const
 {
     return d->typedString;
--- branches/KDE/3.5/kdelibs/kio/kio/kurifilter.h #585659:585660
@@ -185,7 +185,7 @@
      *
      * @param url the string to be filtered.
      */
-    void setData( const QString& url ) { init( url ); }
+    void setData( const QString& url ) { reinit( url ); }
 
     /**
      * Same as above except the argument is a URL.
@@ -196,7 +196,7 @@
      *
      * @param url the URL to be filtered.
      */
-    void setData( const KURL& url ) { init( url ); }
+    void setData( const KURL& url ) { reinit( url ); }
 
     /**
      * Sets the absolute path to be used whenever the supplied
@@ -290,7 +290,7 @@
      *
      * @return an instance of a KURIFilterData object.
      */
-    KURIFilterData& operator=( const KURL& url ) { init( url ); return *this; }
+    KURIFilterData& operator=( const KURL& url ) { reinit( url ); return *this; }
 
     /**
      * Overloaded assigenment operator.
@@ -300,7 +300,7 @@
      *
      * @return an instance of a KURIFilterData object.
      */
-    KURIFilterData& operator=( const QString& url ) { init( url ); return *this; }
+    KURIFilterData& operator=( const QString& url ) { reinit( url ); return *this; }
 
 protected:
 
@@ -317,6 +317,12 @@
     void init( const QString& url = QString::null );
 
 private:
+
+    // BC hack to avoid leaking KURIFilterDataPrivate objects.
+    // setData() and operator= used to call init() without deleting `d'
+    void reinit(const KURL& url);
+    void reinit(const QString& url = QString::null);
+
     bool m_bCheckForExecutables;
     bool m_bChanged;
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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