mirror of
https://github.com/nickshanks/ResKnife.git
synced 2025-01-02 13:30:55 +00:00
Fixed bug in NuTemplateEditor that messed up element values. -- it wasn't in copying the template elements, but rather the table got out of sync when an exception was thrown inNuTemplateElement::setStringValue:
This commit is contained in:
parent
524c6532df
commit
4a2c00a0a2
6
Cocoa/English.lproj/Application.nib/info.nib
generated
6
Cocoa/English.lproj/Application.nib/info.nib
generated
@ -7,16 +7,16 @@
|
|||||||
<key>IBEditorPositions</key>
|
<key>IBEditorPositions</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>246</key>
|
<key>246</key>
|
||||||
<string>12 513 340 222 0 0 1024 746 </string>
|
<string>344 386 340 222 0 0 1024 746 </string>
|
||||||
<key>29</key>
|
<key>29</key>
|
||||||
<string>28 222 347 44 0 0 1024 746 </string>
|
<string>33 294 347 44 0 0 1024 746 </string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>IBFramework Version</key>
|
<key>IBFramework Version</key>
|
||||||
<string>326.0</string>
|
<string>326.0</string>
|
||||||
<key>IBOpenObjects</key>
|
<key>IBOpenObjects</key>
|
||||||
<array>
|
<array>
|
||||||
<integer>246</integer>
|
|
||||||
<integer>29</integer>
|
<integer>29</integer>
|
||||||
|
<integer>246</integer>
|
||||||
</array>
|
</array>
|
||||||
<key>IBSystem Version</key>
|
<key>IBSystem Version</key>
|
||||||
<string>7A202</string>
|
<string>7A202</string>
|
||||||
|
BIN
Cocoa/English.lproj/Application.nib/objects.nib
generated
BIN
Cocoa/English.lproj/Application.nib/objects.nib
generated
Binary file not shown.
@ -39,7 +39,8 @@
|
|||||||
-(id) copyWithZone: (NSZone*)zone
|
-(id) copyWithZone: (NSZone*)zone
|
||||||
{
|
{
|
||||||
NuTemplateElement* el = [[[self class] allocWithZone: zone] initForType: type withLabel: label];
|
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;
|
return el;
|
||||||
}
|
}
|
||||||
@ -72,7 +73,7 @@
|
|||||||
|
|
||||||
-(void) setContaining: (NSMutableArray*)arr
|
-(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
|
-(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
|
@end
|
||||||
|
@ -10,11 +10,17 @@
|
|||||||
#import "NuTemplateGroupElement.h"
|
#import "NuTemplateGroupElement.h"
|
||||||
|
|
||||||
|
|
||||||
|
@class NuTemplateLSTEElement;
|
||||||
|
|
||||||
|
|
||||||
@interface NuTemplateLSTBElement : NuTemplateGroupElement
|
@interface NuTemplateLSTBElement : NuTemplateGroupElement
|
||||||
{
|
{
|
||||||
|
NuTemplateLSTEElement* endElement; // Template to create our "list end" element from.
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) showCreateResourceSheet: (id)sender;
|
-(IBAction) showCreateResourceSheet: (id)sender;
|
||||||
|
|
||||||
|
-(void) setEndElement: (NuTemplateLSTEElement*)e;
|
||||||
|
-(NuTemplateLSTEElement*) endElement;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -12,6 +12,13 @@
|
|||||||
|
|
||||||
@implementation NuTemplateLSTBElement
|
@implementation NuTemplateLSTBElement
|
||||||
|
|
||||||
|
-(void) dealloc
|
||||||
|
{
|
||||||
|
[endElement release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
-(void) readSubElementsFrom: (NuTemplateStream*)stream
|
-(void) readSubElementsFrom: (NuTemplateStream*)stream
|
||||||
{
|
{
|
||||||
while( [stream bytesToGo] > 0 )
|
while( [stream bytesToGo] > 0 )
|
||||||
@ -19,7 +26,10 @@
|
|||||||
NuTemplateElement* obj = [stream readOneElement];
|
NuTemplateElement* obj = [stream readOneElement];
|
||||||
|
|
||||||
if( [[obj type] isEqualToString: @"LSTE"] )
|
if( [[obj type] isEqualToString: @"LSTE"] )
|
||||||
|
{
|
||||||
|
endElement = [obj retain];
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
[subElements addObject: obj];
|
[subElements addObject: obj];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,7 +55,8 @@
|
|||||||
{
|
{
|
||||||
while( [stream bytesToGo] > 0 )
|
while( [stream bytesToGo] > 0 )
|
||||||
{
|
{
|
||||||
nextItem = [self copy]; // Make another list item just like this one.
|
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.
|
[containing addObject: nextItem]; // Add it below ourselves.
|
||||||
[nextItem readDataFrom:stream]; // Read it the same way we were.
|
[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.
|
[nextItem setContaining: containing]; // Set "containing" *after* readDataFrom so it doesn't pass the "containing == nil" check above.
|
||||||
@ -53,9 +64,10 @@
|
|||||||
|
|
||||||
// Now add a terminating 'LSTE' item:
|
// Now add a terminating 'LSTE' item:
|
||||||
NuTemplateLSTEElement* tlee;
|
NuTemplateLSTEElement* tlee;
|
||||||
tlee = [NuTemplateLSTEElement elementForType:@"LSTE" withLabel:label];
|
tlee = [[endElement copy] autorelease];
|
||||||
[containing addObject: tlee];
|
[containing addObject: tlee];
|
||||||
[tlee setContaining: containing];
|
[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.
|
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.
|
[containing removeObject:self]; // Remove the LSTB.
|
||||||
}
|
}
|
||||||
else
|
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
|
-(IBAction) showCreateResourceSheet: (id)sender
|
||||||
{
|
{
|
||||||
unsigned idx = [containing indexOfObject:self];
|
unsigned idx = [containing indexOfObject:self];
|
||||||
NuTemplateElement* te = [self copy];
|
NuTemplateGroupElement* te = [[self copy] autorelease];
|
||||||
|
|
||||||
[containing insertObject:te atIndex:idx+1];
|
[containing insertObject:te atIndex:idx+1];
|
||||||
[te setContaining:containing];
|
[te setContaining:containing];
|
||||||
}
|
}
|
||||||
@ -85,8 +121,8 @@
|
|||||||
|
|
||||||
-(IBAction) clear: (id)sender
|
-(IBAction) clear: (id)sender
|
||||||
{
|
{
|
||||||
[containing removeObject: self];
|
[[self retain] autorelease]; // Make sure we don't go away right now. That may surprise the one who called clear, or otherwise be bad.
|
||||||
[self autorelease];
|
[containing removeObject: self]; // Remove us from the array we're in. (this releases us once)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,9 +12,12 @@
|
|||||||
|
|
||||||
@interface NuTemplateLSTEElement : NuTemplateGroupElement
|
@interface NuTemplateLSTEElement : NuTemplateGroupElement
|
||||||
{
|
{
|
||||||
|
NuTemplateGroupElement* groupElemTemplate; // The item of which we're to create a copy.
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) showCreateResourceSheet: (id)sender;
|
-(IBAction) showCreateResourceSheet: (id)sender;
|
||||||
|
|
||||||
|
-(void) setGroupElemTemplate: (NuTemplateGroupElement*)e;
|
||||||
|
-(NuTemplateGroupElement*) groupElemTemplate;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -12,6 +12,25 @@
|
|||||||
|
|
||||||
@implementation NuTemplateLSTEElement
|
@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
|
-(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
|
-(IBAction) showCreateResourceSheet: (id)sender
|
||||||
{
|
{
|
||||||
unsigned idx = [containing indexOfObject:self];
|
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];
|
[containing insertObject:ge atIndex:idx];
|
||||||
[ge setContaining: containing];
|
[ge setContaining: containing];
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@
|
|||||||
// Loop over template and read each field:
|
// Loop over template and read each field:
|
||||||
while( currElement = [enny nextObject] )
|
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.
|
[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];
|
[currElement setContaining: resourceStructure];
|
||||||
@ -319,7 +319,7 @@
|
|||||||
return( [selElement validateMenuItem: item] );
|
return( [selElement validateMenuItem: item] );
|
||||||
else if( [item action] == @selector(clear:) )
|
else if( [item action] == @selector(clear:) )
|
||||||
return( selElement != nil && [selElement respondsToSelector: @selector(clear:)] );
|
return( selElement != nil && [selElement respondsToSelector: @selector(clear:)] );
|
||||||
else return [super validateMenuItem:item];
|
else return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2654,11 +2654,11 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>Development version 0.5d1</string>
|
<string>Development version 0.5d2</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>ResK</string>
|
<string>ResK</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>0.5d1</string>
|
<string>0.5d2</string>
|
||||||
<key>NSMainNibFile</key>
|
<key>NSMainNibFile</key>
|
||||||
<string>Application</string>
|
<string>Application</string>
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
|
Loading…
Reference in New Issue
Block a user