Fix a minor memory leak in the loader
authorstaikos <staikos@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jul 2007 17:21:29 +0000 (17:21 +0000)
committerstaikos <staikos@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jul 2007 17:21:29 +0000 (17:21 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24114 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitQt/Api/qwebnetworkinterface.cpp
WebKitQt/ChangeLog

index f2cc2e79c5c23181140ac65ca896193b2ed43a62..5c7302f4df1f4d3e68da869a0d535afdba730e74 100644 (file)
@@ -31,6 +31,7 @@
 #include <qnetworkproxy.h>
 #include <qurl.h>
 #include <QAuthenticator>
+#include <QCoreApplication>
 #include <QSslError>
 
 #include "ResourceHandle.h"
@@ -669,6 +670,14 @@ void QWebNetworkInterfacePrivate::parseDataUrl(QWebNetworkJob* job)
   
 */
 
+static bool gRoutineAdded = false;
+
+static void gCleanupInterface()
+{
+    delete default_interface;
+    default_interface = 0;
+}
+
 /*!
   Sets a new default interface that will be used by all of WebKit
   for downloading data from the internet.
@@ -680,6 +689,10 @@ void QWebNetworkInterface::setDefaultInterface(QWebNetworkInterface *defaultInte
     if (default_interface)
         delete default_interface;
     default_interface = defaultInterface;
+    if (!gRoutineAdded) {
+        qAddPostRoutine(gCleanupInterface);
+        gRoutineAdded = true;
+    }
 }
 
 /*!
@@ -689,8 +702,9 @@ void QWebNetworkInterface::setDefaultInterface(QWebNetworkInterface *defaultInte
 */
 QWebNetworkInterface *QWebNetworkInterface::defaultInterface()
 {
-    if (!default_interface)
+    if (!default_interface) {
         setDefaultInterface(new QWebNetworkInterface);
+    }
     return default_interface;
 }
 
index 757df8b0e7bcba0f66635b3b3ad7485be8258cb4..bb9cab4f01b31087500fa33cd348a8287cc53ff9 100644 (file)
@@ -1,3 +1,12 @@
+2007-07-09  George Staikos  <staikos@kde.org>
+
+        Fix a minor memory leak in the loader.
+
+        * Api/qwebnetworkinterface.cpp:
+        (gCleanupInterface):
+        (QWebNetworkInterface::setDefaultInterface):
+        (QWebNetworkInterface::defaultInterface):
+
 2007-07-09  George Staikos  <staikos@kde.org>
 
         Fix a massive memory leak in the loader.