mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
Preserve version control dictionaries on save
This commit is contained in:
parent
26f135cb88
commit
b1ac753039
|
@ -24,6 +24,7 @@
|
|||
NSString * songGroove;
|
||||
NSNumber * songTempo;
|
||||
NSString * tmpPath;
|
||||
NSFileWrapper * vcsWrapper;
|
||||
|
||||
VLSheetWindow * sheetWin;
|
||||
VLLogWindow * logWin;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
pdfWin = nil;
|
||||
logWin = nil;
|
||||
tmpPath = nil;
|
||||
vcsWrapper = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -47,6 +48,7 @@
|
|||
[songLyricist release];
|
||||
[songComposer release];
|
||||
[songArranger release];
|
||||
[vcsWrapper release];
|
||||
|
||||
if (tmpPath) {
|
||||
[[NSFileManager defaultManager] removeFileAtPath:tmpPath handler:nil];
|
||||
|
@ -190,6 +192,30 @@
|
|||
stringByAppendingPathExtension:extension]];
|
||||
}
|
||||
|
||||
- (BOOL)saveToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation error:(NSError **)outError
|
||||
{
|
||||
NSFileWrapper * preservedVCSWrapper = nil;
|
||||
switch (saveOperation) {
|
||||
case NSSaveToOperation:
|
||||
case NSAutosaveOperation:
|
||||
preservedVCSWrapper = vcsWrapper;
|
||||
[preservedVCSWrapper retain];
|
||||
// Fall through
|
||||
case NSSaveAsOperation:
|
||||
[vcsWrapper release];
|
||||
vcsWrapper = nil;
|
||||
// Fall through
|
||||
case NSSaveOperation:
|
||||
break;
|
||||
}
|
||||
BOOL res = [super saveToURL:absoluteURL ofType:typeName
|
||||
forSaveOperation:saveOperation error:outError];
|
||||
if (!vcsWrapper)
|
||||
vcsWrapper = preservedVCSWrapper;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
- (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError **)outError
|
||||
{
|
||||
if ([typeName isEqual:@"VLNativeType"]) {
|
||||
|
|
|
@ -300,6 +300,8 @@ const char * sSteps = "C DbD EbE F GbG AbA BbB ";
|
|||
autorelease];
|
||||
[wrap addRegularFileWithContents:contents
|
||||
preferredFilename:@"Song"];
|
||||
if (vcsWrapper)
|
||||
[wrap addFileWrapper:vcsWrapper];
|
||||
|
||||
return wrap;
|
||||
}
|
||||
|
@ -456,8 +458,13 @@ int8_t sStepToPitch[] = {
|
|||
|
||||
- (BOOL)readFromXMLFileWrapper:(NSFileWrapper *)wrapper error:(NSError **)outError
|
||||
{
|
||||
return [self readFromXMLData: [[[wrapper fileWrappers] objectForKey:@"Song"]
|
||||
regularFileContents]
|
||||
NSDictionary * wrappers = [wrapper fileWrappers];
|
||||
if ((vcsWrapper = [wrappers objectForKey:@"CVS"])
|
||||
|| (vcsWrapper = [wrappers objectForKey:@".svn"])
|
||||
)
|
||||
[vcsWrapper retain];
|
||||
return [self readFromXMLData:
|
||||
[[wrappers objectForKey:@"Song"] regularFileContents]
|
||||
error:outError];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user