reopening a file in the internal editor now works w/o crashing

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@8491 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Robert Slover 2001-01-07 13:44:42 +00:00
parent 457634d06f
commit 62b5d849d3
2 changed files with 13 additions and 8 deletions

View file

@ -84,7 +84,7 @@ extern NSString *PCProjectBuildDidStopNotification;
- (void)openFileInInternalEditor:(NSString *)file; - (void)openFileInInternalEditor:(NSString *)file;
- (NSWindow *)editorForFile:(NSString *)aFile; - (NSWindow *)editorForFile:(NSString *)aFile;
- (void)windowDidClose:(NSNotification *)aNotif; - (void)windowWillClose:(NSNotification *)aNotif;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Server // Server

View file

@ -89,11 +89,13 @@
- (void)openFileInInternalEditor:(NSString *)file - (void)openFileInInternalEditor:(NSString *)file
{ {
if ([openDocuments objectForKey:file]) { NSWindow *editorWindow = nil;
[[openDocuments objectForKey:file] makeKeyAndOrderFront:self];
if ((editorWindow = [openDocuments objectForKey:file])) {
[editorWindow makeKeyAndOrderFront:self];
} }
else { else {
NSWindow *editorWindow = [self editorForFile:file]; editorWindow = [self editorForFile:file];
[editorWindow setDelegate:self]; [editorWindow setDelegate:self];
[editorWindow center]; [editorWindow center];
@ -129,19 +131,19 @@
[textView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; [textView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[textView setBackgroundColor:[NSColor whiteColor]]; [textView setBackgroundColor:[NSColor whiteColor]];
[[textView textContainer] setWidthTracksTextView:YES]; [[textView textContainer] setWidthTracksTextView:YES];
[textView autorelease];
scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect (-1,-1,514,322)]; scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect (-1,-1,514,322)];
[scrollView setDocumentView:textView]; [scrollView setDocumentView:textView];
[textView release];
//[textView setMinSize:NSMakeSize(0.0,[scrollView contentSize].height)]; //[textView setMinSize:NSMakeSize(0.0,[scrollView contentSize].height)];
[[textView textContainer] setContainerSize:NSMakeSize([scrollView contentSize].width,1e7)]; [[textView textContainer] setContainerSize:NSMakeSize([scrollView contentSize].width,1e7)];
[scrollView setHasHorizontalScroller: YES]; [scrollView setHasHorizontalScroller: YES];
[scrollView setHasVerticalScroller: YES]; [scrollView setHasVerticalScroller: YES];
[scrollView setBorderType: NSBezelBorder]; [scrollView setBorderType: NSBezelBorder];
[scrollView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)]; [scrollView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
[scrollView autorelease];
[[window contentView] addSubview:scrollView]; [[window contentView] addSubview:scrollView];
[scrollView release];
/* /*
* Will be replaced when a real editor is available... * Will be replaced when a real editor is available...
@ -152,11 +154,14 @@
return [window autorelease]; return [window autorelease];
} }
- (void)windowDidClose:(NSNotification *)aNotif - (void)windowWillClose:(NSNotification *)aNotif
{ {
NSWindow *window = [aNotif object]; // Otherwise it crashes when reopening the same file?...
NSWindow *window = [[aNotif object] retain];
/*
[openDocuments removeObjectForKey:[window title]]; [openDocuments removeObjectForKey:[window title]];
*/
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------