Reviewed by Beth Dakin.
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Aug 2005 16:45:12 +0000 (16:45 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Aug 2005 16:45:12 +0000 (16:45 +0000)
        - fixed <rdar://problem/4227019> Several 32-byte leaks after choosing pop-up menu at dzone198.apple.com

        Test cases added: none, doesn't affect layout. I did execute run-layout-tests to verify that there
        were no surprises though.

        * khtml/ecma/xmlhttprequest.h:
        use SharedPtr for onReadyStateChangeListener and onLoadListener
        * khtml/ecma/xmlhttprequest.cpp:
        (KJS::XMLHttpRequest::getValueProperty):
        use notNull() instead of testing SharedPtrs against 0
        (KJS::XMLHttpRequest::putValueProperty):
        use reset() to set values of SharedPtrs; eliminate ref()s that had no deref()s
        (KJS::XMLHttpRequest::mark):
        use notNull() instead of testing SharedPtrs against 0
        (KJS::XMLHttpRequest::XMLHttpRequest):
        don't initialize SharedPtrs
        (KJS::XMLHttpRequest::changeState):
        use notNull() instead of testing SharedPtrs against 0

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@10288 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/ecma/xmlhttprequest.cpp
WebCore/khtml/ecma/xmlhttprequest.h

index 96f4721..99a366c 100644 (file)
@@ -1,3 +1,26 @@
+2005-08-22  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Beth Dakin.
+        
+        - fixed <rdar://problem/4227019> Several 32-byte leaks after choosing pop-up menu at dzone198.apple.com
+
+        Test cases added: none, doesn't affect layout. I did execute run-layout-tests to verify that there
+        were no surprises though.
+
+        * khtml/ecma/xmlhttprequest.h:
+        use SharedPtr for onReadyStateChangeListener and onLoadListener
+        * khtml/ecma/xmlhttprequest.cpp:
+        (KJS::XMLHttpRequest::getValueProperty):
+        use notNull() instead of testing SharedPtrs against 0
+        (KJS::XMLHttpRequest::putValueProperty):
+        use reset() to set values of SharedPtrs; eliminate ref()s that had no deref()s
+        (KJS::XMLHttpRequest::mark):
+        use notNull() instead of testing SharedPtrs against 0
+        (KJS::XMLHttpRequest::XMLHttpRequest):
+        don't initialize SharedPtrs
+        (KJS::XMLHttpRequest::changeState):
+        use notNull() instead of testing SharedPtrs against 0
+
 2005-08-22  David Harrison  <harrison@apple.com>
 
         Reviewed by Justin.
index bcb5438..00e40ab 100644 (file)
@@ -184,13 +184,13 @@ ValueImp *XMLHttpRequest::getValueProperty(ExecState *exec, int token) const
   case StatusText:
     return getStatusText();
   case Onreadystatechange:
-   if (onReadyStateChangeListener && onReadyStateChangeListener->listenerObjImp()) {
+   if (onReadyStateChangeListener.notNull() && onReadyStateChangeListener->listenerObjImp()) {
      return onReadyStateChangeListener->listenerObj();
    } else {
      return Null();
    }
   case Onload:
-   if (onLoadListener && onLoadListener->listenerObjImp()) {
+   if (onLoadListener.notNull() && onLoadListener->listenerObjImp()) {
      return onLoadListener->listenerObj();
    } else {
      return Null();
@@ -210,12 +210,10 @@ void XMLHttpRequest::putValueProperty(ExecState *exec, int token, ValueImp *valu
 {
   switch(token) {
   case Onreadystatechange:
-    onReadyStateChangeListener = Window::retrieveActive(exec)->getJSUnprotectedEventListener(value, true);
-    if (onReadyStateChangeListener) onReadyStateChangeListener->ref();
+    onReadyStateChangeListener.reset(Window::retrieveActive(exec)->getJSUnprotectedEventListener(value, true));
     break;
   case Onload:
-    onLoadListener = Window::retrieveActive(exec)->getJSUnprotectedEventListener(value, true);
-    if (onLoadListener) onLoadListener->ref();
+    onLoadListener.reset(Window::retrieveActive(exec)->getJSUnprotectedEventListener(value, true));
     break;
   default:
     kdWarning() << "HTMLDocument::putValueProperty unhandled token " << token << endl;
@@ -226,10 +224,10 @@ void XMLHttpRequest::mark()
 {
   DOMObject::mark();
 
-  if (onReadyStateChangeListener)
+  if (onReadyStateChangeListener.notNull())
     onReadyStateChangeListener->mark();
 
-  if (onLoadListener)
+  if (onLoadListener.notNull())
     onLoadListener->mark();
 }
 
@@ -240,8 +238,6 @@ XMLHttpRequest::XMLHttpRequest(ExecState *exec, DOM::DocumentImpl *d)
     async(true),
     job(0),
     state(Uninitialized),
-    onReadyStateChangeListener(0),
-    onLoadListener(0),
     decoder(0),
     createdDocument(false),
     aborted(false)
@@ -262,7 +258,7 @@ void XMLHttpRequest::changeState(XMLHttpRequestState newState)
   if (state != newState) {
     state = newState;
     
-    if (doc && doc->part() && onReadyStateChangeListener != 0) {
+    if (doc && doc->part() && onReadyStateChangeListener.notNull()) {
       int ignoreException;
       EventImpl *ev = doc->createEvent("HTMLEvents", ignoreException);
       ev->ref();
@@ -271,7 +267,7 @@ void XMLHttpRequest::changeState(XMLHttpRequestState newState)
       ev->deref();
     }
     
-    if (doc && doc->part() && state == Completed && onLoadListener != 0) {
+    if (doc && doc->part() && state == Completed && onLoadListener.notNull()) {
       int ignoreException;
       EventImpl *ev = doc->createEvent("HTMLEvents", ignoreException);
       ev->ref();
index 21fdd03..adfa4a5 100644 (file)
@@ -125,8 +125,8 @@ namespace KJS {
     KIO::TransferJob * job;
 
     XMLHttpRequestState state;
-    JSUnprotectedEventListener *onReadyStateChangeListener;
-    JSUnprotectedEventListener *onLoadListener;
+    khtml::SharedPtr<JSUnprotectedEventListener> onReadyStateChangeListener;
+    khtml::SharedPtr<JSUnprotectedEventListener> onLoadListener;
 
     khtml::Decoder *decoder;
     QString encoding;