mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Fixes for case _document == nil
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11114 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
53ad3452ff
commit
49f6931245
1 changed files with 51 additions and 26 deletions
|
@ -66,6 +66,7 @@
|
|||
[self _windowDidLoad];
|
||||
}
|
||||
|
||||
[self setDocument: nil];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -97,8 +98,23 @@
|
|||
- (void) setDocument: (NSDocument *)document
|
||||
{
|
||||
// FIXME - this is RETAINed and never RELEASEd ...
|
||||
ASSIGN(_document, document);
|
||||
ASSIGN (_document, document);
|
||||
[self _synchronizeWindowTitleWithDocumentName];
|
||||
|
||||
if (_document != nil)
|
||||
{
|
||||
[_window setReleasedWhenClosed: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If you want the window to be deallocated when closed, you
|
||||
need to observe the NSWindowWillCloseNotification (or
|
||||
implement the window's delegate windowWillClose: method) and
|
||||
autorelease the window controller in that method. That will
|
||||
then release the window when the window controller is
|
||||
released. */
|
||||
[_window setReleasedWhenClosed: NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) document
|
||||
|
@ -151,29 +167,33 @@
|
|||
{
|
||||
if ([notification object] == _window)
|
||||
{
|
||||
if ([_window delegate] == self)
|
||||
{
|
||||
[_window setDelegate: nil];
|
||||
}
|
||||
if ([_window windowController] == self)
|
||||
{
|
||||
[_window setWindowController: nil];
|
||||
}
|
||||
|
||||
/*
|
||||
* If the window is set to isReleasedWhenClosed, it will release
|
||||
* itself, so nil out our reference so we don't release it again
|
||||
* We may want to unilaterally turn off the setting in the NSWindow
|
||||
* instance so it doesn't cause problems.
|
||||
*
|
||||
* Apple's implementation doesn't seem to deal with this case, and
|
||||
* crashes if isReleaseWhenClosed is set.
|
||||
*/
|
||||
/* We only need to do something if the window is set to be
|
||||
released when closed (which should only happen if _document
|
||||
!= nil). In this case, we release everything; otherwise,
|
||||
well the window is closed but nothing is released so there's
|
||||
nothing to do here. */
|
||||
if ([_window isReleasedWhenClosed])
|
||||
{
|
||||
if ([_window delegate] == self)
|
||||
{
|
||||
[_window setDelegate: nil];
|
||||
}
|
||||
if ([_window windowController] == self)
|
||||
{
|
||||
[_window setWindowController: nil];
|
||||
}
|
||||
|
||||
/*
|
||||
* If the window is set to isReleasedWhenClosed, it will release
|
||||
* itself, so nil out our reference so we don't release it again
|
||||
*
|
||||
* Apple's implementation doesn't seem to deal with this case, and
|
||||
* crashes if isReleaseWhenClosed is set.
|
||||
*/
|
||||
_window = nil;
|
||||
|
||||
[_document _removeWindowController: self];
|
||||
}
|
||||
[_document _removeWindowController: self];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,14 +244,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (NSString *) windowTitleForDocumentDisplayName:(NSString *)displayName
|
||||
- (NSString *) windowTitleForDocumentDisplayName: (NSString *)displayName
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
- (void) _synchronizeWindowTitleWithDocumentName
|
||||
{
|
||||
if (_document)
|
||||
if (_document != nil)
|
||||
{
|
||||
NSString *filename = [_document fileName];
|
||||
NSString *displayName = [_document displayName];
|
||||
|
@ -332,6 +352,15 @@
|
|||
{
|
||||
[self setWindow: [_document _transferWindowOwnership]];
|
||||
}
|
||||
|
||||
if (_document != nil)
|
||||
{
|
||||
[_window setReleasedWhenClosed: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_window setReleasedWhenClosed: NO];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -340,10 +369,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* There's no way I'll ever get these compatible if Apple's versions
|
||||
* actually encode anything, sigh
|
||||
*/
|
||||
- (id) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
return [self init];
|
||||
|
|
Loading…
Reference in a new issue