Changeset 35579 in webkit


Ignore:
Timestamp:
Aug 5, 2008 3:57:53 PM (16 years ago)
Author:
andersca@apple.com
Message:

2008-08-05 Anders Carlsson <andersca@apple.com>

Reviewed by Darin.

Make the main thread object deallocator work with subclasses.


  • WebView/MainThreadObjectDeallocator.h:
  • WebView/MainThreadObjectDeallocator.mm: (deallocCallback): Call the correct dealloc method.


(scheduleDeallocateOnMainThread):
Store both the class and the instance, so we know which dealloc method to call.


  • WebView/WebView.mm: (-[WebViewPrivate dealloc]): Schedule deallocation on the main thread.
Location:
trunk/WebKit/mac
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/mac/ChangeLog

    r35573 r35579  
     12008-08-05  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        Make the main thread object deallocator work with subclasses.
     6       
     7        * WebView/MainThreadObjectDeallocator.h:
     8        * WebView/MainThreadObjectDeallocator.mm:
     9        (deallocCallback):
     10        Call the correct dealloc method.
     11               
     12        (scheduleDeallocateOnMainThread):
     13        Store both the class and the instance, so we know which dealloc method to call.
     14       
     15        * WebView/WebView.mm:
     16        (-[WebViewPrivate dealloc]):
     17        Schedule deallocation on the main thread.
     18
    1192008-08-05  Dan Bernstein  <mitz@apple.com>
    220
  • trunk/WebKit/mac/WebView/MainThreadObjectDeallocator.h

    r34812 r35579  
    2929#include <objc/objc.h>
    3030
    31 bool scheduleDeallocateOnMainThread(id object);
     31// The 'Class' that should be passed in here is the class of the
     32// object that implements the dealloc method that this function is called from.
     33bool scheduleDeallocateOnMainThread(Class cls, id object);
    3234
    3335#endif // MainThreadDeallocator_h
  • trunk/WebKit/mac/WebView/MainThreadObjectDeallocator.mm

    r34812 r35579  
    2626#include "MainThreadObjectDeallocator.h"
    2727
     28#include <objc/objc-runtime.h>
     29#include <wtf/Assertions.h>
    2830#include <wtf/MainThread.h>
     31
     32#ifdef BUILDING_ON_TIGER
     33static inline IMP method_getImplementation(Method method)
     34{
     35    return method->method_imp;
     36}
     37#endif
     38
     39typedef std::pair<Class, id> ClassAndIdPair;
    2940
    3041static void deallocCallback(void* context)
    3142{
    32     id object = static_cast<id>(context);
     43    ClassAndIdPair* pair = static_cast<ClassAndIdPair*>(context);
    3344   
    34     [object dealloc];
     45    Method method = class_getInstanceMethod(pair->first, @selector(dealloc));
     46   
     47    IMP imp = method_getImplementation(method);
     48    imp(pair->second, @selector(dealloc));
     49   
     50    delete pair;
    3551}
    3652
    37 bool scheduleDeallocateOnMainThread(id object)
     53bool scheduleDeallocateOnMainThread(Class cls, id object)
    3854{
     55    ASSERT([object isKindOfClass:cls]);
     56   
    3957    if (pthread_main_np() != 0)
    4058        return false;
    4159
    42     callOnMainThread(deallocCallback, object);
     60    ClassAndIdPair* pair = new ClassAndIdPair(cls, object);
     61    callOnMainThread(deallocCallback, pair);
    4362    return true;
    4463}
  • trunk/WebKit/mac/WebView/WebView.mm

    r35573 r35579  
    492492
    493493- (void)dealloc
    494 {
    495     if (scheduleDeallocateOnMainThread(self))
    496         return;
    497    
     494{   
    498495    ASSERT(applicationIsTerminating || !page);
    499496    ASSERT(applicationIsTerminating || !preferences);
     
    20732070- (void)dealloc
    20742071{
     2072    if (scheduleDeallocateOnMainThread([WebView class], self))
     2073        return;
     2074
    20752075    // call close to ensure we tear-down completely
    20762076    // this maintains our old behavior for existing applications
Note: See TracChangeset for help on using the changeset viewer.