Changeset 35579 in webkit
- Timestamp:
- Aug 5, 2008 3:57:53 PM (16 years ago)
- Location:
- trunk/WebKit/mac
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/mac/ChangeLog
r35573 r35579 1 2008-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 1 19 2008-08-05 Dan Bernstein <mitz@apple.com> 2 20 -
trunk/WebKit/mac/WebView/MainThreadObjectDeallocator.h
r34812 r35579 29 29 #include <objc/objc.h> 30 30 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. 33 bool scheduleDeallocateOnMainThread(Class cls, id object); 32 34 33 35 #endif // MainThreadDeallocator_h -
trunk/WebKit/mac/WebView/MainThreadObjectDeallocator.mm
r34812 r35579 26 26 #include "MainThreadObjectDeallocator.h" 27 27 28 #include <objc/objc-runtime.h> 29 #include <wtf/Assertions.h> 28 30 #include <wtf/MainThread.h> 31 32 #ifdef BUILDING_ON_TIGER 33 static inline IMP method_getImplementation(Method method) 34 { 35 return method->method_imp; 36 } 37 #endif 38 39 typedef std::pair<Class, id> ClassAndIdPair; 29 40 30 41 static void deallocCallback(void* context) 31 42 { 32 id object = static_cast<id>(context);43 ClassAndIdPair* pair = static_cast<ClassAndIdPair*>(context); 33 44 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; 35 51 } 36 52 37 bool scheduleDeallocateOnMainThread( id object)53 bool scheduleDeallocateOnMainThread(Class cls, id object) 38 54 { 55 ASSERT([object isKindOfClass:cls]); 56 39 57 if (pthread_main_np() != 0) 40 58 return false; 41 59 42 callOnMainThread(deallocCallback, object); 60 ClassAndIdPair* pair = new ClassAndIdPair(cls, object); 61 callOnMainThread(deallocCallback, pair); 43 62 return true; 44 63 } -
trunk/WebKit/mac/WebView/WebView.mm
r35573 r35579 492 492 493 493 - (void)dealloc 494 { 495 if (scheduleDeallocateOnMainThread(self)) 496 return; 497 494 { 498 495 ASSERT(applicationIsTerminating || !page); 499 496 ASSERT(applicationIsTerminating || !preferences); … … 2073 2070 - (void)dealloc 2074 2071 { 2072 if (scheduleDeallocateOnMainThread([WebView class], self)) 2073 return; 2074 2075 2075 // call close to ensure we tear-down completely 2076 2076 // this maintains our old behavior for existing applications
Note: See TracChangeset
for help on using the changeset viewer.