* Source/GSXibLoader.m (GSXibKeyedUnarchiver -_preProcessXib:):

Release the document.
        Patch by Doug Simons <doug.simons@testplant.com>
        * Source/GSXibLoader.m: Fix a problem where owner,
        * firstResponder and application
        were put in the list of top-level objects, creating a
retain-cycle.
        * Source/NSViewController.m: Fix a problem where view
        * controllers
        did not release their top-level objects as expected.
        * Source/NSWindowController.m: Fix a problem where window
        controllers did not release their top-level objects as expected.
        Changes made in occordance with
        https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html
        Patch by Jonathan Gillaspie <jonathan.gillaspie@testplant.com>



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36134 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2013-02-14 09:22:56 +00:00
parent 0a4708d4d0
commit 0e308561c1
4 changed files with 32 additions and 12 deletions

View file

@ -1,3 +1,18 @@
2013-02-14 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSXibLoader.m (GSXibKeyedUnarchiver -_preProcessXib:):
Release the document.
Patch by Doug Simons <doug.simons@testplant.com>
* Source/GSXibLoader.m: Fix a problem where owner, firstResponder and application
were put in the list of top-level objects, creating a retain-cycle.
* Source/NSViewController.m: Fix a problem where view controllers
did not release their top-level objects as expected.
* Source/NSWindowController.m: Fix a problem where window
controllers did not release their top-level objects as expected.
Changes made in occordance with
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html
Patch by Jonathan Gillaspie <jonathan.gillaspie@testplant.com>
2013-02-14 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSDragView.m

View file

@ -870,15 +870,14 @@
obj = [obj nibInstantiate];
}
if (obj != nil)
// IGNORE file's owner, first responder and NSApplication instances...
if ((obj != nil) && (obj != owner) && (obj != first) && (obj != app))
{
[topLevelObjects addObject: obj];
// All top level objects must be released by the caller to avoid
// leaking, unless they are going to be released by other nib
// objects on behalf of the owner.
// IGNORE file's owner, first responder and NSApplication instances...
if ((obj != owner) && (obj != first) && (obj != app))
RETAIN(obj);
RETAIN(obj);
}
if (([obj isKindOfClass: [NSMenu class]]) &&
@ -1055,7 +1054,7 @@
NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data
options:0
error:NULL];
if(document == nil)
if (document == nil)
{
NSLog(@"%s:DOCUMENT IS NIL: %@\n", __PRETTY_FUNCTION__, document);
}
@ -1114,13 +1113,13 @@
NSDebugLLog(@"PREXIB", @"%s:customClassDict: %@\n", __PRETTY_FUNCTION__, customClassDict);
if([customClassDict count] > 0)
if ([customClassDict count] > 0)
{
NSArray *objectRecords = nil;
NSEnumerator *en = [[customClassDict allKeys] objectEnumerator];
NSString *key = nil;
while((key = [en nextObject]) != nil)
while ((key = [en nextObject]) != nil)
{
NSString *keyValue = [key stringByReplacingOccurrencesOfString:@".CustomClassName" withString:@""];
NSString *className = [customClassDict objectForKey:key];
@ -1132,11 +1131,11 @@
objectRecords = [document nodesForXPath:objectRecordXpath error:NULL];
NSString *refId = nil;
if([objectRecords count] > 0)
if ([objectRecords count] > 0)
{
id record = nil;
NSEnumerator *oen = [objectRecords objectEnumerator];
while((record = [oen nextObject]) != nil)
while ((record = [oen nextObject]) != nil)
{
if ([record isMemberOfClass:[NSXMLElement class]])
{
@ -1159,9 +1158,9 @@
classAttr = [classNode attributeForName:@"class"];
[classAttr setStringValue:className];
if(cls != nil)
if (cls != nil)
{
if([cls respondsToSelector:@selector(cellClass)])
if ([cls respondsToSelector:@selector(cellClass)])
{
NSArray *cellNodes = nil;
id cellNode = nil;
@ -1169,7 +1168,7 @@
NSString *cellXpath = [NSString stringWithFormat:@"//object[@id=\"%@\"]/object[@key=\"NSCell\"]",refId];
cellNodes = [document nodesForXPath:cellXpath
error:NULL];
if([cellNodes count] > 0)
if ([cellNodes count] > 0)
{
NSString *cellClassString = NSStringFromClass(cellClass);
id cellAttr = nil;
@ -1187,6 +1186,7 @@
}
}
result = [document XMLData];
RELEASE(document);
}
return result;

View file

@ -50,6 +50,8 @@
- (void) dealloc
{
// View Controllers are expect to release their own top-level objects
[_topLevelObjects makeObjectsPerformSelector: @selector(release)];
DESTROY(_nibName);
DESTROY(_nibBundle);
DESTROY(_representedObject);

View file

@ -26,6 +26,7 @@
Boston, MA 02110-1301, USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSBundle.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSEnumerator.h>
@ -129,6 +130,8 @@
- (void) dealloc
{
// Window Controllers are expect to release their own top-level objects
[_top_level_objects makeObjectsPerformSelector: @selector(release)];
[self setWindow: nil];
RELEASE(_window_nib_name);
RELEASE(_window_nib_path);