[webkit-changes] cvs commit: WebCore/khtml/ecma kjs_events.cpp kjs_events.h kjs_window.cpp

Adele adele at opensource.apple.com
Tue Aug 30 17:49:26 PDT 2005


adele       05/08/30 17:49:26

  Modified:    .        Tag: Safari-2-0-branch ChangeLog
               khtml/ecma Tag: Safari-2-0-branch kjs_events.cpp
                        kjs_events.h kjs_window.cpp
  Log:
          Merged fix from TOT to Safari-2-0-branch
  
      2005-08-30  John Sullivan  <sullivan at apple.com>
  
          Reviewed by Maciej.
  
          Test cases added: none, doesn't affect layout
  
          - fixed <rdar://problem/4237183> REGRESSION (Denver): crash in
          JSUnprotectedEventListener::~JSUnprotectedEventListener
  
          * khtml/ecma/kjs_events.cpp:
          (KJS::JSUnprotectedEventListener::~JSUnprotectedEventListener):
          check for nil window pointer
          (KJS::JSUnprotectedEventListener::clearWindowObj):
          new method, sets window pointer to nil
  
          (KJS::JSEventListener::~JSEventListener):
          (KJS::JSEventListener::clearWindowObj):
          same changes for this class. We don't think the bug would ever happen for
          this similar class, but we're not completely sure, so best to play it safe.
  
          * khtml/ecma/kjs_events.h:
          declaration of new clearWindowObj methods
  
          * khtml/ecma/kjs_window.cpp:
          (KJS::Window::~Window):
          iterate through event listeners, clearing their window pointers
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.16  +31 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.1.2.15
  retrieving revision 1.1.2.16
  diff -u -r1.1.2.15 -r1.1.2.16
  --- ChangeLog	29 Aug 2005 01:15:17 -0000	1.1.2.15
  +++ ChangeLog	31 Aug 2005 00:49:22 -0000	1.1.2.16
  @@ -1,3 +1,34 @@
  +2005-08-30  Adele Peterson  <adele at apple.com>
  +
  +        Merged fix from TOT to Safari-2-0-branch
  +
  +    2005-08-30  John Sullivan  <sullivan at apple.com>
  +
  +        Reviewed by Maciej.
  +
  +        Test cases added: none, doesn't affect layout
  +        
  +        - fixed <rdar://problem/4237183> REGRESSION (Denver): crash in 
  +        JSUnprotectedEventListener::~JSUnprotectedEventListener
  +
  +        * khtml/ecma/kjs_events.cpp:
  +        (KJS::JSUnprotectedEventListener::~JSUnprotectedEventListener):
  +        check for nil window pointer
  +        (KJS::JSUnprotectedEventListener::clearWindowObj):
  +        new method, sets window pointer to nil
  +        
  +        (KJS::JSEventListener::~JSEventListener):
  +        (KJS::JSEventListener::clearWindowObj):
  +        same changes for this class. We don't think the bug would ever happen for
  +        this similar class, but we're not completely sure, so best to play it safe.
  +        
  +        * khtml/ecma/kjs_events.h:
  +        declaration of new clearWindowObj methods
  +        
  +        * khtml/ecma/kjs_window.cpp:
  +        (KJS::Window::~Window):
  +        iterate through event listeners, clearing their window pointers
  +
   === Safari-416.5 ===
   
   2005-08-28  Adele Peterson  <adele at apple.com>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.42.8.6  +17 -2     WebCore/khtml/ecma/kjs_events.cpp
  
  Index: kjs_events.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_events.cpp,v
  retrieving revision 1.42.8.5
  retrieving revision 1.42.8.6
  diff -u -r1.42.8.5 -r1.42.8.6
  --- kjs_events.cpp	22 Jul 2005 03:09:48 -0000	1.42.8.5
  +++ kjs_events.cpp	31 Aug 2005 00:49:24 -0000	1.42.8.6
  @@ -154,7 +154,9 @@
   JSUnprotectedEventListener::~JSUnprotectedEventListener()
   {
       if (listener.imp()) {
  -      static_cast<Window*>(win.imp())->jsUnprotectedEventListeners.remove(listener.imp());
  +        if (!win.isNull()) {
  +            static_cast<Window*>(win.imp())->jsUnprotectedEventListeners.remove(listener.imp());
  +        }
       }
   }
   
  @@ -168,6 +170,12 @@
       return win;
   }
   
  +void JSUnprotectedEventListener::clearWindowObj()
  +{
  +    win = Object();
  +}
  +
  +
   void JSUnprotectedEventListener::mark()
   {
     ObjectImp *listenerImp = listener.imp();
  @@ -191,7 +199,9 @@
   JSEventListener::~JSEventListener()
   {
       if (listener.imp()) {
  -      static_cast<Window*>(win.imp())->jsEventListeners.remove(listener.imp());
  +        if (!win.isNull()) {
  +          static_cast<Window*>(win.imp())->jsEventListeners.remove(listener.imp());
  +        }
       }
       //fprintf(stderr,"JSEventListener::~JSEventListener this=%p listener=%p\n",this,listener.imp());
   }
  @@ -206,6 +216,11 @@
       return win;
   }
   
  +void JSEventListener::clearWindowObj()
  +{
  +    win = Object();
  +}
  +
   // -------------------------------------------------------------------------
   
   JSLazyEventListener::JSLazyEventListener(QString _code, const Object &_win, NodeImpl *_originalNode, int lineno)
  
  
  
  1.24.8.2  +2 -0      WebCore/khtml/ecma/kjs_events.h
  
  Index: kjs_events.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_events.h,v
  retrieving revision 1.24.8.1
  retrieving revision 1.24.8.2
  diff -u -r1.24.8.1 -r1.24.8.2
  --- kjs_events.h	27 Apr 2005 00:58:14 -0000	1.24.8.1
  +++ kjs_events.h	31 Aug 2005 00:49:24 -0000	1.24.8.2
  @@ -55,6 +55,7 @@
       virtual ~JSUnprotectedEventListener();
       virtual Object listenerObj() const;
       virtual Object windowObj() const;
  +    void clearWindowObj();
       void mark();
     protected:
       Object listener;
  @@ -67,6 +68,7 @@
       virtual ~JSEventListener();
       virtual Object listenerObj() const;
       virtual Object windowObj() const;
  +    void clearWindowObj();
     protected:
       mutable ProtectedObject listener;
       ProtectedObject win;
  
  
  
  1.146.8.10 +14 -2     WebCore/khtml/ecma/kjs_window.cpp
  
  Index: kjs_window.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.cpp,v
  retrieving revision 1.146.8.9
  retrieving revision 1.146.8.10
  diff -u -r1.146.8.9 -r1.146.8.10
  --- kjs_window.cpp	2 Aug 2005 21:26:15 -0000	1.146.8.9
  +++ kjs_window.cpp	31 Aug 2005 00:49:24 -0000	1.146.8.10
  @@ -336,8 +336,20 @@
   
   Window::~Window()
   {
  -  kdDebug(6070) << "Window::~Window this=" << this << " part=" << m_part << endl;
  -  delete winq;
  +    // Clear any backpointers to the window
  +    QPtrDictIterator<JSUnprotectedEventListener> unprotectedListeners(jsUnprotectedEventListeners);
  +    while (unprotectedListeners.current()) {
  +        unprotectedListeners.current()->clearWindowObj();
  +        ++unprotectedListeners;
  +    }
  +    
  +    QPtrDictIterator<JSEventListener> listeners(jsEventListeners);
  +    while (listeners.current()) {
  +        listeners.current()->clearWindowObj();
  +        ++listeners;
  +    }
  +    
  +    delete winq;
   }
   
   KJS::Interpreter *Window::interpreter() const
  
  
  



More information about the webkit-changes mailing list