From dc84b62997c3cd70f15d14f60c64d3a9fa163fb3 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 23 Jun 2009 12:00:49 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20issue=20for=20showing=20an=20error?= =?UTF-8?q?=20alert=20sheet=20inside=20of=20a=20endSheet=20selector=20of?= =?UTF-8?q?=20an=20other=20sheet:=20-=20introduced=20-(void)showErrorSheet?= =?UTF-8?q?WithTitle:(id)error=20--=20error=20is=20an=20array=20of=20title?= =?UTF-8?q?=20and=20message=20-=20this=20can=20be=20called=20via=20[self?= =?UTF-8?q?=20performSelector:@selector(showErrorSheetWithTitle:)=20withOb?= =?UTF-8?q?ject:=20afterDelay:]=20-=20this=20avoids=20a=20crash=20of=20the?= =?UTF-8?q?=20current=20table=20window?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TableSource.h | 2 ++ Source/TableSource.m | 31 +++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Source/TableSource.h b/Source/TableSource.h index 9776620e..06528e04 100644 --- a/Source/TableSource.h +++ b/Source/TableSource.h @@ -63,6 +63,8 @@ NSUserDefaults *prefs; } +-(void)showErrorSheetWithTitle:(id)error; + //table methods - (void)loadTable:(NSString *)aTable; - (IBAction)reloadTable:(id)sender; diff --git a/Source/TableSource.m b/Source/TableSource.m index 24fd13a5..2f66d1fb 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -847,10 +847,13 @@ fetches the result as an array with a dictionary for each row in it [tablesListInstance setContentRequiresReload:YES]; [tableDataInstance resetColumnData]; } else { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove field %@.\nMySQL said: %@", @"message of panel when field cannot be removed"), - [[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"Field"], - [mySQLConnection getLastErrorMessage]]); + [self performSelector:@selector(showErrorSheetWithTitle:) + withObject:[NSArray arrayWithObjects:NSLocalizedString(@"Error", @"error"), + [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove field %@.\nMySQL said: %@", @"message of panel when field cannot be removed"), + [[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"Field"], + [mySQLConnection getLastErrorMessage]], + nil] + afterDelay:0.3]; } } } else if ( [contextInfo isEqualToString:@"removeindex"] ) { @@ -866,8 +869,12 @@ fetches the result as an array with a dictionary for each row in it if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { [self loadTable:selectedTable]; } else { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove index.\nMySQL said: %@", @"message of panel when index cannot be removed"), [mySQLConnection getLastErrorMessage]]); + [self performSelector:@selector(showErrorSheetWithTitle:) + withObject:[NSArray arrayWithObjects:NSLocalizedString(@"Error", @"error"), + [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove index.\nMySQL said: %@", @"message of panel when index cannot be removed"), + [mySQLConnection getLastErrorMessage]], + nil] + afterDelay:0.3]; } } } else if ( [contextInfo isEqualToString:@"cannotremovefield"]) { @@ -876,6 +883,18 @@ fetches the result as an array with a dictionary for each row in it } +/* + * Show Error sheet (can be called from inside of a endSheet selector) + * via [self performSelector:@selector(showErrorSheetWithTitle:) withObject: afterDelay:] + */ +-(void)showErrorSheetWithTitle:(id)error +{ + // error := first object is the title , second the message, only one button OK + NSBeginAlertSheet([error objectAtIndex:0], NSLocalizedString(@"OK", @"OK button"), + nil, nil, tableWindow, self, nil, nil, nil, + [error objectAtIndex:1]); +} + /** * This method is called as part of Key Value Observing which is used to watch for preference changes which effect the interface. */ -- cgit v1.2.3