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

John sullivan at opensource.apple.com
Tue Aug 30 11:20:26 PDT 2005


sullivan    05/08/30 11:20:25

  Modified:    .        ChangeLog
               khtml/ecma kjs_events.cpp kjs_events.h kjs_window.cpp
  Log:
          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
  1.41      +27 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- ChangeLog	30 Aug 2005 09:55:40 -0000	1.40
  +++ ChangeLog	30 Aug 2005 18:20:22 -0000	1.41
  @@ -1,3 +1,30 @@
  +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
  +
   2005-08-30  Maciej Stachowiak  <mjs at apple.com>
   
           Add some test cases that I apparently forgot to commit before.
  
  
  
  1.58      +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.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- kjs_events.cpp	25 Aug 2005 17:47:01 -0000	1.57
  +++ kjs_events.cpp	30 Aug 2005 18:20:24 -0000	1.58
  @@ -184,7 +184,9 @@
   JSUnprotectedEventListener::~JSUnprotectedEventListener()
   {
       if (listener) {
  -      static_cast<Window*>(win)->jsUnprotectedEventListeners.remove(listener);
  +        if (win) {
  +            static_cast<Window*>(win)->jsUnprotectedEventListeners.remove(listener);
  +        }
       }
   }
   
  @@ -198,6 +200,12 @@
       return win;
   }
   
  +void JSUnprotectedEventListener::clearWindowObj()
  +{
  +    win = NULL;
  +}
  +
  +
   void JSUnprotectedEventListener::mark()
   {
     ObjectImp *listenerImp = listener;
  @@ -220,7 +228,9 @@
   {
       if (ObjectImp *l = listener) {
           ObjectImp *w = win;
  -        static_cast<Window *>(w)->jsEventListeners.remove(l);
  +        if (w) {
  +            static_cast<Window *>(w)->jsEventListeners.remove(l);
  +        }
       }
   }
   
  @@ -234,6 +244,11 @@
       return win;
   }
   
  +void JSEventListener::clearWindowObj()
  +{
  +    win = NULL;
  +}
  +
   // -------------------------------------------------------------------------
   
   JSLazyEventListener::JSLazyEventListener(QString _code, ObjectImp *_win, NodeImpl *_originalNode, int lineno)
  
  
  
  1.31      +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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- kjs_events.h	8 Aug 2005 04:07:41 -0000	1.30
  +++ kjs_events.h	30 Aug 2005 18:20:24 -0000	1.31
  @@ -61,6 +61,7 @@
       virtual ~JSUnprotectedEventListener();
       virtual ObjectImp *listenerObj() const;
       virtual ObjectImp *windowObj() const;
  +    void clearWindowObj();
       void mark();
     protected:
       ObjectImp *listener;
  @@ -73,6 +74,7 @@
       virtual ~JSEventListener();
       virtual ObjectImp *listenerObj() const;
       virtual ObjectImp *windowObj() const;
  +    void clearWindowObj();
     protected:
       mutable ProtectedObject listener;
       ProtectedObject win;
  
  
  
  1.175     +14 -1     WebCore/khtml/ecma/kjs_window.cpp
  
  Index: kjs_window.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.cpp,v
  retrieving revision 1.174
  retrieving revision 1.175
  diff -u -r1.174 -r1.175
  --- kjs_window.cpp	25 Aug 2005 17:47:01 -0000	1.174
  +++ kjs_window.cpp	30 Aug 2005 18:20:24 -0000	1.175
  @@ -338,7 +338,20 @@
   
   Window::~Window()
   {
  -  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;
   }
   
   Interpreter *Window::interpreter() const
  
  
  



More information about the webkit-changes mailing list