Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
The export code caused an exception when no database was selected but…
… the filename contained the database token (fixes #2145)
- Loading branch information
|
@@ -346,15 +346,15 @@ - (NSString *)expandCustomFilenameFormatUsingTableName:(NSString *)table |
|
|
NSString *tokenContent = [filenamePart tokenContent]; |
|
|
|
|
|
if ([tokenContent isEqualToString:NSLocalizedString(@"host", @"export filename host token")]) { |
|
|
[string appendString:[tableDocumentInstance host]]; |
|
|
[string appendStringOrNil:[tableDocumentInstance host]]; |
|
|
|
|
|
} |
|
|
else if ([tokenContent isEqualToString:NSLocalizedString(@"database", @"export filename database token")]) { |
|
|
[string appendString:[tableDocumentInstance database]]; |
|
|
[string appendStringOrNil:[tableDocumentInstance database]]; |
|
|
|
|
|
} |
|
|
else if ([tokenContent isEqualToString:NSLocalizedString(@"table", @"table")]) { |
|
|
[string appendString:(table) ? table : @""]; |
|
|
[string appendStringOrNil:table]; |
|
|
} |
|
|
else if ([tokenContent isEqualToString:NSLocalizedString(@"date", @"export filename date token")]) { |
|
|
[dateFormatter setDateStyle:NSDateFormatterShortStyle]; |
|
@@ -380,7 +380,7 @@ - (NSString *)expandCustomFilenameFormatUsingTableName:(NSString *)table |
|
|
[string appendString:[dateFormatter stringFromDate:[NSDate date]]]; |
|
|
} |
|
|
else if ([tokenContent isEqualToString:NSLocalizedString(@"favorite", @"export filename favorite name token")]) { |
|
|
[string appendString:[tableDocumentInstance name]]; |
|
|
[string appendStringOrNil:[tableDocumentInstance name]]; |
|
|
} |
|
|
} |
|
|
else { |
|
|
|
@@ -441,7 +441,7 @@ - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(id)aCell rect: |
|
|
} else { |
|
|
if([[filtered objectAtIndex:rowIndex] objectForKey:@"list"]) { |
|
|
NSMutableString *tt = [NSMutableString string]; |
|
|
[tt appendString:([[filtered objectAtIndex:rowIndex] objectForKey:@"type"]) ? [[filtered objectAtIndex:rowIndex] objectForKey:@"type"] : @""]; |
|
|
[tt appendStringOrNil:[[filtered objectAtIndex:rowIndex] objectForKey:@"type"]]; |
|
|
[tt appendString:@"\n"]; |
|
|
[tt appendString:NSLocalizedString(@"Type Declaration:", @"type declaration header")]; |
|
|
[tt appendString:@"\n"]; |
|
|
|
@@ -101,3 +101,17 @@ static inline id NSMutableAttributedStringAttributeAtIndex(NSMutableAttributedSt |
|
|
*/ |
|
|
- (BOOL)nonConsecutivelySearchString:(NSString *)other matchingRanges:(NSArray **)submatches; |
|
|
@end |
|
|
|
|
|
@interface NSMutableString (SPStringAdditions) |
|
|
/** |
|
|
* nil-safe variant of setString: |
|
|
* nil will be interpreted as @"" instead of throwing an exception |
|
|
*/ |
|
|
- (void)setStringOrNil:(NSString *)aString; |
|
|
|
|
|
/** |
|
|
* nil-safe variant of appendString: |
|
|
* nil will be interpreted as @"" instead of throwing an exception |
|
|
*/ |
|
|
- (void)appendStringOrNil:(NSString *)aString; |
|
|
@end |
|
@@ -562,3 +562,17 @@ static NSInteger _smallestOf(NSInteger a, NSInteger b, NSInteger c) |
|
|
|
|
|
return min; |
|
|
} |
|
|
|
|
|
@implementation NSMutableString (SPStringAdditions) |
|
|
|
|
|
- (void)setStringOrNil:(NSString *)aString |
|
|
{ |
|
|
[self setString:(aString? aString : @"")]; |
|
|
} |
|
|
|
|
|
- (void)appendStringOrNil:(NSString *)aString |
|
|
{ |
|
|
[self appendString:(aString? aString : @"")]; |
|
|
} |
|
|
|
|
|
@end |