]> err.no Git - sope/commitdiff
fixed a crasher on MacOS
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Thu, 16 Nov 2006 15:50:46 +0000 (15:50 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Thu, 16 Nov 2006 15:50:46 +0000 (15:50 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1380 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-core/NGExtensions/ChangeLog
sope-core/NGExtensions/EOExt.subproj/EOCacheDataSource.m
sope-core/NGExtensions/Version

index a47b29c829c5c46bb44c8b6ee5739170a423c0fe..216f535e4f6e0b1021e4943c65129ef50b8af9f7 100644 (file)
@@ -1,3 +1,9 @@
+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
index 0364ee0b5105ab56883ed94d0b920fff72effcaf..3479ff91f3e6170d852739a58da6f811af297652 100644 (file)
@@ -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.
 
 - (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];
@@ -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];
     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 */
index c55de3fbd7ebddae349a5f75818373bef5fd3b41..e3c6c10cf3c4027001aac568e2e4e4c208deddad 100644 (file)
@@ -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