Xcode debugging: Exception cached?
I have an issue with cached error handling in X-Code. I commented a particular line out, but i still get the same error for this line.
I cleaned the project, i deleted the build folder, i replaced (deleted and imported again) all references. But still i get an error in the line where is nothing. Even if i comment out everything, i get the same error.
- (void) setTileSource: (id<RMTileSource>)newTileSource
{
if (tileSource == newTileSource)
return;
RMCachedTileSource *newCachedTileSource = [RMCachedTileSource cachedTileSourceWithSource:newTileSource];
newCachedTileSource = [newCachedTileSource retain];
[tileSource release];
tileSource = newCachedTileSource;
---> here is the SIGABRT exception
// NSAssert(([tileSource minZoom] - minZoom) <= 1.0, @"Graphics & memory are
[projection release];
projection = [[tileSource projection] retain];
[mercatorToTileProjection release];
mercatorToTileProjection = [[tileSource mercatorToTileProjection] retain];
[imagesOnScreen setTileSource:t开发者_运维技巧ileSource];
[tileLoader reset];
[tileLoader reload];
}
I suspect that means that the exception is not caused by the line you commented out.
Firstly, why do you do this:
newCachedTileSource = [newCachedTileSource retain];
retain
returns self. You don't need to assign the result to the same object pointer. If the library overrides retain to return something different, the library is broken.
Secondly, I think this might be a bug:
[projection release];
projection = [[tileSource projection] retain];
If projection == [tileSource projection]
before the release, it may be possible it is somehow getting over released. Does the problem go away if you do:
RMProjection* newProjection = [[tileSource projection] retain];
[projection release];
projection = newProjection;
Ideally, you would create a synthesized retain property for projection (actually projection could just get the value from the tileSource) like so:
-(RMProjection*) projection
{
return [[self tileSoruce] projection];
}
Same for mercatorToTileProjection.
Shouldn't you retain the titleSource
? Try,
tileSource = [newCachedTileSource copy];
Change
[tileSource release];
to
[tileSource autorelease];
精彩评论