Bizarre crashing bug
Bizarre crashing bug
- Subject: Bizarre crashing bug
- From: Ken Tozier <email@hidden>
- Date: Sun, 17 Jun 2007 18:22:01 -0400
Hi
I have two methods that are exact copies of each other, the only
difference being the method name but one crashes my app and the other
works. Initially, the methods did different tasks but, in a
desperation move, I copied the body of the working method replacing
the body of crashing one, did a clean all targets, rebuilt. Same
outcome. The bad one still crashes and the good one doesn't.
I did a global search to see if the method name might be conflicting
with a framework method name but there were no duplicates. I filled
my code with NSLogs and the path to the "updatePublicationView "
dispatch method is identical in the run log. What could possibly be
causing this? I'm completely stumped.
Thanks for any help
Ken
Here's the defines for the three display modes
#define ViewModePage @"page"
#define ViewModeDocument @"document"
#define ViewModeStatus @"status"
Here's the code I use to choose which mode to display (hard coded for
the moment)
[self setViewMode: ViewModePage]; //<- works
//[self setViewMode: ViewModeStatus]; //<- crashes application
Here's the method that dispatches to the appropriate display mode
handler
- (void) updatePublicationView
{
if ([viewMode isEqualToString: ViewModePage])
[self drawPageModeView];
else if ([viewMode isEqualToString: ViewModeStatus])
[self drawStatusViewMode];
else if ([viewMode isEqualToString: ViewModeDocument])
[self drawDocumentModeView];
}
And here are the two methods
// This one crashes the app
- (void) drawStatusViewMode
{
if (publicationView != nil)
{
NSSize pubContentSize = [publicationView contentSize];
NSRect matrixFrame = [publicationView frame];
NSView *documentView = nil;
if (pageMatrices != nil)
[pageMatrices release];
[publicationView releaseDocumentView];
documentView = [publicationView documentView];
pageMatrices = [[NSMutableDictionary alloc] init];
matrixFrame.size.width = pubContentSize.width;
matrixFrame.size.height = pubContentSize.height;
KWrappingMatrix *matrix = [self matrixWithFrame: matrixFrame
pages: pages
title: @"Pages"];
[documentView addSubview: matrix];
NSLog(@"drawPageModeView documentView: %@", documentView);
[slider setInitialValue: [matrix scale]];
[publicationView setNeedsDisplay: YES];
}
}
// This one works perfectly
- (void) drawPageModeView
{
if (publicationView != nil)
{
NSSize pubContentSize = [publicationView contentSize];
NSRect matrixFrame = [publicationView bounds];
NSView *documentView = nil;
if (pageMatrices != nil)
[pageMatrices release];
[publicationView releaseDocumentView];
documentView = [publicationView documentView];
pageMatrices = [[NSMutableDictionary alloc] init];
matrixFrame.size.width = pubContentSize.width;
matrixFrame.size.height = pubContentSize.height;
KWrappingMatrix *matrix = [self matrixWithFrame: matrixFrame
pages: pages
title: @"Pages"];
[documentView addSubview: matrix];
NSLog(@"drawPageModeView documentView: %@", documentView);
[slider setInitialValue: [matrix scale]];
[publicationView setNeedsDisplay: YES];
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden