"BAD_ACCESS" error when showing window [newbie to cocoa]
"BAD_ACCESS" error when showing window [newbie to cocoa]
- Subject: "BAD_ACCESS" error when showing window [newbie to cocoa]
- From: rwb <email@hidden>
- Date: Mon, 10 Feb 2003 12:10:48 -0500
Hi folks,
I've been looking through the archives trying to find an solution to
this but nothing is working. I am new to the objective-c/cocoa world,
though the code is evolving from a working os9 Toolbox based version.
The biggest change is trying to get everything into a Document based
concept.
The problem occurs when the window shows. The model section of the
code init's fine, and everything seems okay in the
windowControllerDidLoad method. Stepping through the execution shows
no problems in the render method, which touches all the critical
objects. Following the backtrace, the error happens in the greyed out
-[NSWindowController showWindow:] call.
The only thing that does not seem right is that the OpenGlContext never
seems to pick up a view. I test it in the windowControllerDidLoad and
it comes up null, even after explicitly setting it.
My nib file has gone from a complex one with sliders and a subclassed
OpenGLView to a very simple window with only an OpenGLView. The
Document object (FLODoc) has a IBOutlet connected to the GLView.
Could this be a compilation problem? the following line appears on the
console after the build but before anything else:
"MacOS Support/Universal/Interfaces/CIncludes: Command not found."
Even if this is not the problem, where is it coming from and how do I
make it go away?
Hopefully I am just missing something obvious, any ideas?
Here is the Document class implementation. I was using a separate view
controller but dropped that (for now) to try to get to something that
works.
///////////////////////////////////////////////////////////////////////
//////////
//
// FLODoc.m
// FLO v0
//
// Created by rwb on Fri Jan 31 2003.
// Copyright (c) 2003 Rebus Studios. All rights reserved.
//
#import "FLODoc.h"
@implementation FLODoc
- (id)init
{
NSRect defaultRect;
defaultRect.origin.x = DOC_VIEW_RECT_X;
defaultRect.origin.y = DOC_VIEW_RECT_Y;
defaultRect.size.width = DOC_VIEW_RECT_WIDTH;
defaultRect.size.height = DOC_VIEW_RECT_HIGHT;
NSLog(@"FLODoc init");
[super init];
if (self) {
pause = YES;
// init ObjectBox and add default drawing
objBox = [[FLOObjectBox alloc] initWithFrame:defaultRect];
if(!objBox) {
NSLog(@"FLODoc error: unable to alloc objBox");
//[self dealloc];
}
NSLog(@"FLODoc init success");
}
return self;
}
-(void)render {
[glCtx makeCurrentContext];
[objBox execute];
[glView setNeedsDisplay:YES];
}
- (NSString *) windowNibName {
return @"SimpleView";
}
- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
NSLog(@"FLODoc windowControllerDidLoadNib");
[super windowControllerDidLoadNib:aController];
[objBox setViewFrame:[glView frame]];
glCtx = [glView openGLContext];
[glCtx setView:glView];
//build and draw the default drawing
[self loadDefault];
[self render];
NSLog(@"glCtx view %@",[[glCtx view] description]);
NSLog(@"FLODoc windowControllerDidLoadNib exit");
}
//
// loadDefault make this drawing at startup
//
- (void)loadDefault {
FLOObject *temp1,*temp2;
temp1 = [objBox newObjectOfType:@"place"
withName:@"placeRect1"];
temp2 = [objBox newObjectOfType:@"rect" withName:@"rect1"];
[temp1 addChildBelow:temp2];
[[objBox curScene] addChildBelow:temp1];
//
}
- (NSData *)dataRepresentationOfType:(NSString *)aType
{
// Insert code here to write your document from the given data.
You can also choose to override -fileWrapperRepresentationOfType: or
-writeToFile:ofType: instead.
return nil;
}
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
// Insert code here to read your document from the given data. You
can also choose to override -loadFileWrapperRepresentation:ofType: or
-readFromFile:ofType: instead.
return YES;
}
@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.