+2006-11-16 Helge Hess <helge.hess@opengroupware.org>
+
+ * EOExt.subproj/EOCacheDataSource.m: the NSTimer of the datasource
+ does not retain the datasource anymore to avoid keeping them around
+ w/o any other refers (fixes a buserror on MacOS) (v4.5.190)
+
2006-11-02 Helge Hess <helge.hess@opengroupware.org>
* NGQuotedPrintableCoding.m: added NSData method to decode QP as per
/*
- Copyright (C) 2000-2005 SKYRIX Software AG
+ Copyright (C) 2000-2006 SKYRIX Software AG
+ Copyright (C) 2006 Helge Hess
This file is part of SOPE.
- (void)_clearCache;
@end
+@interface EOCacheDataSourceTimer : NSObject
+{
+@public
+ EOCacheDataSource *ds; /* non-retained! */
+}
+
+@end
+
@implementation EOCacheDataSource
- (id)initWithDataSource:(EODataSource *)_ds {
- (void)dealloc {
[self _removeObserverForSource:self->source];
- [self->timer invalidate];
+
+ [self->timer invalidate];
[self->timer release];
+
[self->source release];
[self->cache release];
[super dealloc];
/* accessors */
- (void)setSource:(EODataSource *)_source {
+ if (self->source == _source)
+ return;
+
[self _removeObserverForSource:self->source];
ASSIGN(self->source, _source);
[self _registerForSource:self->source];
self->cache = [[self->source fetchObjects] retain];
if (self->timeout > 0) {
+ EOCacheDataSourceTimer *holder;
+
+ /* this object is here to avoid a retain cycle */
+ holder = [[EOCacheDataSourceTimer alloc] init];
+ holder->ds = self;
+
self->time =
[[NSDate date] timeIntervalSinceReferenceDate] + self->timeout;
- self->timer = [NSTimer scheduledTimerWithTimeInterval:self->timeout
- target:self
- selector:@selector(clear)
- userInfo:nil repeats:NO];
- self->timer = [self->timer retain];
+ /* the timer retains the holder, but no the DS */
+ self->timer = [[NSTimer scheduledTimerWithTimeInterval:self->timeout
+ target:holder
+ selector:@selector(clear)
+ userInfo:nil repeats:NO] retain];
+
+ [holder release]; holder = nil;
}
PROFILE_CHECKPOINT("cache miss");
}
}
@end /* EOCacheDataSource */
+
+@implementation EOCacheDataSourceTimer
+
+- (void)clear {
+ [self->ds clear];
+}
+
+@end /* EOCacheDataSourceTimer */