diff --git a/Cocoa/English.lproj/Application.nib/info.nib b/Cocoa/English.lproj/Application.nib/info.nib index bf6f114..b2a2e02 100644 --- a/Cocoa/English.lproj/Application.nib/info.nib +++ b/Cocoa/English.lproj/Application.nib/info.nib @@ -7,16 +7,16 @@ IBEditorPositions 246 - 12 513 340 222 0 0 1024 746 + 344 386 340 222 0 0 1024 746 29 - 28 222 347 44 0 0 1024 746 + 33 294 347 44 0 0 1024 746 IBFramework Version 326.0 IBOpenObjects - 246 29 + 246 IBSystem Version 7A202 diff --git a/Cocoa/English.lproj/Application.nib/objects.nib b/Cocoa/English.lproj/Application.nib/objects.nib index fc5f804..f6bf6db 100644 Binary files a/Cocoa/English.lproj/Application.nib/objects.nib and b/Cocoa/English.lproj/Application.nib/objects.nib differ diff --git a/NuTemplateEditor/NuTemplateElement.m b/NuTemplateEditor/NuTemplateElement.m index a4de1e0..263db7f 100644 --- a/NuTemplateEditor/NuTemplateElement.m +++ b/NuTemplateEditor/NuTemplateElement.m @@ -39,7 +39,8 @@ -(id) copyWithZone: (NSZone*)zone { NuTemplateElement* el = [[[self class] allocWithZone: zone] initForType: type withLabel: label]; - //NuTemplateElement* el = [[[self class] alloc] initForType:type withLabel:label]; + + [el setContaining: [self containing]]; return el; } @@ -72,7 +73,7 @@ -(void) setContaining: (NSMutableArray*)arr { - containing = arr; // It contains *us*, so it's unlikely it survives longer than we'd do, and we don't want to create a ring. + containing = arr; // It contains *us*, so it's unlikely we survive longer than it'd do, and we don't want to create a ring. } -(NSMutableArray*) containing @@ -123,5 +124,11 @@ } +-(void) setStringValue: (NSString*)str +{ + // We need this method. Otherwise key/value coding throws an exception which screws up the table. + NSLog(@"This template item can't accept any values, especially not \"%@\".",str); +} + @end diff --git a/NuTemplateEditor/NuTemplateLSTBElement.h b/NuTemplateEditor/NuTemplateLSTBElement.h index c195f57..49327c2 100644 --- a/NuTemplateEditor/NuTemplateLSTBElement.h +++ b/NuTemplateEditor/NuTemplateLSTBElement.h @@ -10,11 +10,17 @@ #import "NuTemplateGroupElement.h" +@class NuTemplateLSTEElement; + + @interface NuTemplateLSTBElement : NuTemplateGroupElement { - + NuTemplateLSTEElement* endElement; // Template to create our "list end" element from. } -(IBAction) showCreateResourceSheet: (id)sender; +-(void) setEndElement: (NuTemplateLSTEElement*)e; +-(NuTemplateLSTEElement*) endElement; + @end diff --git a/NuTemplateEditor/NuTemplateLSTBElement.m b/NuTemplateEditor/NuTemplateLSTBElement.m index f45df23..6a4c370 100644 --- a/NuTemplateEditor/NuTemplateLSTBElement.m +++ b/NuTemplateEditor/NuTemplateLSTBElement.m @@ -12,6 +12,13 @@ @implementation NuTemplateLSTBElement +-(void) dealloc +{ + [endElement release]; + [super dealloc]; +} + + -(void) readSubElementsFrom: (NuTemplateStream*)stream { while( [stream bytesToGo] > 0 ) @@ -19,7 +26,10 @@ NuTemplateElement* obj = [stream readOneElement]; if( [[obj type] isEqualToString: @"LSTE"] ) + { + endElement = [obj retain]; break; + } [subElements addObject: obj]; } } @@ -45,17 +55,19 @@ { while( [stream bytesToGo] > 0 ) { - nextItem = [self copy]; // Make another list item just like this one. - [containing addObject: nextItem]; // Add it below ourselves. - [nextItem readDataFrom:stream]; // Read it the same way we were. + nextItem = [[self copy] autorelease]; // Make another list item just like this one. + [nextItem setContaining: nil]; // Make sure it doesn't get into this "if" clause. + [containing addObject: nextItem]; // Add it below ourselves. + [nextItem readDataFrom:stream]; // Read it the same way we were. [nextItem setContaining: containing]; // Set "containing" *after* readDataFrom so it doesn't pass the "containing == nil" check above. } // Now add a terminating 'LSTE' item: NuTemplateLSTEElement* tlee; - tlee = [NuTemplateLSTEElement elementForType:@"LSTE" withLabel:label]; + tlee = [[endElement copy] autorelease]; [containing addObject: tlee]; [tlee setContaining: containing]; + [tlee setGroupElemTemplate: self]; if( bytesToGoAtStart == 0 ) // It's an empty list. Delete this LSTB again, so we only have the empty LSTE. { @@ -63,7 +75,7 @@ [containing removeObject:self]; // Remove the LSTB. } else - [tlee setSubElements: [subElements copy]]; // Make a copy. So each has its own array. + [tlee setSubElements: [[subElements copy] autorelease]]; // Make a copy. So each has its own array. } } @@ -74,10 +86,34 @@ } +-(id) copyWithZone: (NSZone*)zone +{ + NuTemplateLSTBElement* el = [super copyWithZone: zone]; + + [el setEndElement: [self endElement]]; + + return el; +} + +-(void) setEndElement: (NuTemplateLSTEElement*)e +{ + [e retain]; + [endElement release]; + endElement = e; +} + + +-(NuTemplateLSTEElement*) endElement +{ + return endElement; +} + + -(IBAction) showCreateResourceSheet: (id)sender { - unsigned idx = [containing indexOfObject:self]; - NuTemplateElement* te = [self copy]; + unsigned idx = [containing indexOfObject:self]; + NuTemplateGroupElement* te = [[self copy] autorelease]; + [containing insertObject:te atIndex:idx+1]; [te setContaining:containing]; } @@ -85,8 +121,8 @@ -(IBAction) clear: (id)sender { - [containing removeObject: self]; - [self autorelease]; + [[self retain] autorelease]; // Make sure we don't go away right now. That may surprise the one who called clear, or otherwise be bad. + [containing removeObject: self]; // Remove us from the array we're in. (this releases us once) } diff --git a/NuTemplateEditor/NuTemplateLSTEElement.h b/NuTemplateEditor/NuTemplateLSTEElement.h index 280e854..ecd2f6a 100644 --- a/NuTemplateEditor/NuTemplateLSTEElement.h +++ b/NuTemplateEditor/NuTemplateLSTEElement.h @@ -12,9 +12,12 @@ @interface NuTemplateLSTEElement : NuTemplateGroupElement { - + NuTemplateGroupElement* groupElemTemplate; // The item of which we're to create a copy. } -(IBAction) showCreateResourceSheet: (id)sender; +-(void) setGroupElemTemplate: (NuTemplateGroupElement*)e; +-(NuTemplateGroupElement*) groupElemTemplate; + @end diff --git a/NuTemplateEditor/NuTemplateLSTEElement.m b/NuTemplateEditor/NuTemplateLSTEElement.m index f81b439..e69d538 100644 --- a/NuTemplateEditor/NuTemplateLSTEElement.m +++ b/NuTemplateEditor/NuTemplateLSTEElement.m @@ -12,6 +12,25 @@ @implementation NuTemplateLSTEElement +-(void) dealloc +{ + [groupElemTemplate release]; + [super dealloc]; +} + + +-(void) setGroupElemTemplate: (NuTemplateGroupElement*)e +{ + [e retain]; + [groupElemTemplate release]; + groupElemTemplate = e; +} + +-(NuTemplateGroupElement*) groupElemTemplate +{ + return groupElemTemplate; +} + -(void) readSubElementsFrom: (NuTemplateStream*)stream { @@ -55,12 +74,21 @@ } +-(id) copyWithZone: (NSZone*)zone +{ + NuTemplateLSTEElement* el = [super copyWithZone: zone]; + + [el setGroupElemTemplate: [self groupElemTemplate]]; + + return el; +} + + -(IBAction) showCreateResourceSheet: (id)sender { unsigned idx = [containing indexOfObject:self]; - NuTemplateGroupElement* ge = [NuTemplateLSTBElement elementForType:@"LSTB" withLabel:[self label]]; + NuTemplateGroupElement* ge = [[groupElemTemplate copy] autorelease]; - [ge setSubElements: [subElements copy]]; [containing insertObject:ge atIndex:idx]; [ge setContaining: containing]; } diff --git a/NuTemplateEditor/NuTemplateWindowController.m b/NuTemplateEditor/NuTemplateWindowController.m index 4420707..d108598 100644 --- a/NuTemplateEditor/NuTemplateWindowController.m +++ b/NuTemplateEditor/NuTemplateWindowController.m @@ -149,7 +149,7 @@ // Loop over template and read each field: while( currElement = [enny nextObject] ) { - currElement = [currElement copy]; // Copy the template object. + currElement = [[currElement copy] autorelease]; // Copy the template object. [resourceStructure addObject: currElement]; // Add it to our parsed resource data list. Do this right away so the element can append other items should it desire to. [currElement setContaining: resourceStructure]; @@ -319,7 +319,7 @@ return( [selElement validateMenuItem: item] ); else if( [item action] == @selector(clear:) ) return( selElement != nil && [selElement respondsToSelector: @selector(clear:)] ); - else return [super validateMenuItem:item]; + else return NO; } diff --git a/ResKnife.pbproj/project.pbxproj b/ResKnife.pbproj/project.pbxproj index 00965de..3236a15 100644 --- a/ResKnife.pbproj/project.pbxproj +++ b/ResKnife.pbproj/project.pbxproj @@ -2654,11 +2654,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - Development version 0.5d1 + Development version 0.5d2 CFBundleSignature ResK CFBundleVersion - 0.5d1 + 0.5d2 NSMainNibFile Application NSPrincipalClass