From 3bf0cde99766defe5d92c9aa2e19a59a91f1ca3d Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 16 Nov 2006 15:50:46 +0000 Subject: [PATCH] fixed a crasher on MacOS git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1380 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-core/NGExtensions/ChangeLog | 6 +++ .../EOExt.subproj/EOCacheDataSource.m | 44 ++++++++++++++++--- sope-core/NGExtensions/Version | 2 +- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/sope-core/NGExtensions/ChangeLog b/sope-core/NGExtensions/ChangeLog index a47b29c8..216f535e 100644 --- a/sope-core/NGExtensions/ChangeLog +++ b/sope-core/NGExtensions/ChangeLog @@ -1,3 +1,9 @@ +2006-11-16 Helge Hess + + * 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 * NGQuotedPrintableCoding.m: added NSData method to decode QP as per diff --git a/sope-core/NGExtensions/EOExt.subproj/EOCacheDataSource.m b/sope-core/NGExtensions/EOExt.subproj/EOCacheDataSource.m index 0364ee0b..3479ff91 100644 --- a/sope-core/NGExtensions/EOExt.subproj/EOCacheDataSource.m +++ b/sope-core/NGExtensions/EOExt.subproj/EOCacheDataSource.m @@ -1,5 +1,6 @@ /* - 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. @@ -33,6 +34,14 @@ - (void)_clearCache; @end +@interface EOCacheDataSourceTimer : NSObject +{ +@public + EOCacheDataSource *ds; /* non-retained! */ +} + +@end + @implementation EOCacheDataSource - (id)initWithDataSource:(EODataSource *)_ds { @@ -48,8 +57,10 @@ - (void)dealloc { [self _removeObserverForSource:self->source]; - [self->timer invalidate]; + + [self->timer invalidate]; [self->timer release]; + [self->source release]; [self->cache release]; [super dealloc]; @@ -58,6 +69,9 @@ /* accessors */ - (void)setSource:(EODataSource *)_source { + if (self->source == _source) + return; + [self _removeObserverForSource:self->source]; ASSIGN(self->source, _source); [self _registerForSource:self->source]; @@ -97,14 +111,22 @@ 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"); } @@ -211,3 +233,11 @@ } @end /* EOCacheDataSource */ + +@implementation EOCacheDataSourceTimer + +- (void)clear { + [self->ds clear]; +} + +@end /* EOCacheDataSourceTimer */ diff --git a/sope-core/NGExtensions/Version b/sope-core/NGExtensions/Version index c55de3fb..e3c6c10c 100644 --- a/sope-core/NGExtensions/Version +++ b/sope-core/NGExtensions/Version @@ -1,6 +1,6 @@ # version -SUBMINOR_VERSION:=189 +SUBMINOR_VERSION:=190 # v4.3.115 requires libFoundation v1.0.59 # v4.2.72 requires libEOControl v4.2.39 -- 2.39.5