From 5357fd1375d19a6c5de96293b3899f430422a3c0 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 20 Oct 2015 15:24:10 +0200 Subject: Replace a lot of SPBeginAlertSheet()s with the more concise SPOnewayAlertSheet() This should also eliminate a few use-after-free crashes --- Source/SPExtendedTableInfo.m | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'Source/SPExtendedTableInfo.m') diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m index d3b332d0..92b845e9 100644 --- a/Source/SPExtendedTableInfo.m +++ b/Source/SPExtendedTableInfo.m @@ -171,9 +171,11 @@ static NSString *SPMySQLCommentField = @"Comment"; else { [sender selectItemWithTitle:currentEncoding]; - SPBeginAlertSheet(NSLocalizedString(@"Error changing table encoding", @"error changing table encoding message"), - NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table encoding to '%@'.\n\nMySQL said: %@", @"error changing table encoding informative message"), newEncoding, [connection lastErrorMessage]]); + SPOnewayAlertSheet( + NSLocalizedString(@"Error changing table encoding", @"error changing table encoding message"), + [NSApp mainWindow], + [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table encoding to '%@'.\n\nMySQL said: %@", @"error changing table encoding informative message"), newEncoding, [connection lastErrorMessage]] + ); } } @@ -198,9 +200,11 @@ static NSString *SPMySQLCommentField = @"Comment"; else { [sender selectItemWithTitle:currentCollation]; - SPBeginAlertSheet(NSLocalizedString(@"Error changing table collation", @"error changing table collation message"), - NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table collation to '%@'.\n\nMySQL said: %@", @"error changing table collation informative message"), newCollation, [connection lastErrorMessage]]); + SPOnewayAlertSheet( + NSLocalizedString(@"Error changing table collation", @"error changing table collation message"), + [NSApp mainWindow], + [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table collation to '%@'.\n\nMySQL said: %@", @"error changing table collation informative message"), newCollation, [connection lastErrorMessage]] + ); } } @@ -546,9 +550,11 @@ static NSString *SPMySQLCommentField = @"Comment"; [self reloadTable:self]; } else { - SPBeginAlertSheet(NSLocalizedString(@"Error changing table comment", @"error changing table comment message"), - NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table's comment to '%@'.\n\nMySQL said: %@", @"error changing table comment informative message"), newComment, [connection lastErrorMessage]]); + SPOnewayAlertSheet( + NSLocalizedString(@"Error changing table comment", @"error changing table comment message"), + [NSApp mainWindow], + [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table's comment to '%@'.\n\nMySQL said: %@", @"error changing table comment informative message"), newComment, [connection lastErrorMessage]] + ); } } } @@ -650,9 +656,11 @@ static NSString *SPMySQLCommentField = @"Comment"; [tableTypePopUpButton selectItemWithTitle:currentType]; - SPBeginAlertSheet(NSLocalizedString(@"Error changing table type", @"error changing table type message"), - NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table type to '%@'.\n\nMySQL said: %@", @"error changing table type informative message"), newType, [connection lastErrorMessage]]); + SPOnewayAlertSheet( + NSLocalizedString(@"Error changing table type", @"error changing table type message"), + [NSApp mainWindow], + [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table type to '%@'.\n\nMySQL said: %@", @"error changing table type informative message"), newType, [connection lastErrorMessage]] + ); return; } -- cgit v1.2.3 From 57955871fb174eefc56dfedcd8222d2e68272ca5 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 31 Oct 2015 01:26:59 +0100 Subject: Minimal refactoring --- Source/SPExtendedTableInfo.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/SPExtendedTableInfo.m') diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m index 92b845e9..26574621 100644 --- a/Source/SPExtendedTableInfo.m +++ b/Source/SPExtendedTableInfo.m @@ -119,7 +119,7 @@ static NSString *SPMySQLCommentField = @"Comment"; if ([currentType isEqualToString:newType]) return; // If the table is empty, perform the change directly - if ([[[tableDataInstance statusValues] objectForKey:SPMySQLRowsField] isEqualToString:@"0"]) { + if ([[tableDataInstance statusValueForKey:SPMySQLRowsField] isEqualToString:@"0"]) { [self _changeCurrentTableTypeFrom:currentType to:newType]; return; } -- cgit v1.2.3