aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPAppController.m2
-rw-r--r--Source/SPCopyTable.m2
-rw-r--r--Source/SPDatabaseDocument.m17
-rw-r--r--Source/SPTableInfo.h10
-rw-r--r--Source/SPTableInfo.m76
-rw-r--r--Source/SPTextView.m2
-rw-r--r--Source/SPTextViewAdditions.m2
7 files changed, 93 insertions, 18 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 12b9e9a4..ad456b89 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -818,7 +818,7 @@
}
}
}
- } else {
+ } else if([err code] != 9) { // Suppress an error message if command was killed
NSString *errorMessage = [err localizedDescription];
SPBeginAlertSheet(NSLocalizedString(@"BASH Error", @"bash error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil,
[NSString stringWithFormat:@"%@ “%@”:\n%@", NSLocalizedString(@"Error for", @"error for message"), [cmdData objectForKey:@"name"], errorMessage]);
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m
index f06c4700..94e0eb45 100644
--- a/Source/SPCopyTable.m
+++ b/Source/SPCopyTable.m
@@ -960,7 +960,7 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
}
}
}
- } else {
+ } else if([err code] != 9) { // Suppress an error message if command was killed
NSString *errorMessage = [err localizedDescription];
SPBeginAlertSheet(NSLocalizedString(@"BASH Error", @"bash error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil,
[NSString stringWithFormat:@"%@ “%@”:\n%@", NSLocalizedString(@"Error for", @"error for message"), [cmdData objectForKey:@"name"], errorMessage]);
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 23805b12..8ec6ad61 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -3655,6 +3655,7 @@
*/
- (BOOL)parentTabShouldClose
{
+
// If no connection is available, always return YES. Covers initial setup and disconnections.
if(!_isConnected) return YES;
@@ -3673,8 +3674,23 @@
return isSaved;
}
+ // Terminate all running BASH commands
+ for(NSDictionary* cmd in [self runningBASHProcesses]) {
+ NSInteger pid = [[cmd objectForKey:@"pid"] intValue];
+ NSTask *killTask = [[NSTask alloc] init];
+ [killTask setLaunchPath:@"/bin/sh"];
+ [killTask setArguments:[NSArray arrayWithObjects:@"-c", [NSString stringWithFormat:@"kill -9 -%ld", pid], nil]];
+ [killTask launch];
+ [killTask waitUntilExit];
+ [killTask release];
+ }
+
[[SPNavigatorController sharedNavigatorController] performSelectorOnMainThread:@selector(removeConnection:) withObject:[self connectionID] waitUntilDone:YES];
+ // Note that this call does not need to be removed in release builds as leaks analysis output is only
+ // dumped if [[SPLogger logger] setDumpLeaksOnTermination]; has been called first.
+ [[SPLogger logger] dumpLeaks];
+
// Return YES by default
return YES;
}
@@ -3703,6 +3719,7 @@
[createTableSyntaxWindow orderOut:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self setParentWindow:nil];
+
}
/**
diff --git a/Source/SPTableInfo.h b/Source/SPTableInfo.h
index 041f9173..bae3da4e 100644
--- a/Source/SPTableInfo.h
+++ b/Source/SPTableInfo.h
@@ -29,10 +29,18 @@
IBOutlet id tableListInstance;
IBOutlet id tableDataInstance;
IBOutlet id tableDocumentInstance;
-
+
+ IBOutlet NSTableView *activitiesTable;
+
+ IBOutlet NSScrollView *tableInfoScrollView;
+ IBOutlet NSScrollView *activitiesScrollView;
+ IBOutlet NSView *containerView;
+
NSMutableArray *info;
+ NSMutableArray *activities;
}
- (void)tableChanged:(NSNotification *)notification;
+- (void)updateActivities;
@end
diff --git a/Source/SPTableInfo.m b/Source/SPTableInfo.m
index 0270c097..ba24040a 100644
--- a/Source/SPTableInfo.m
+++ b/Source/SPTableInfo.m
@@ -39,7 +39,8 @@
- (id)init
{
if ((self = [super init])) {
- info = [[NSMutableArray alloc] init];
+ info = [[NSMutableArray alloc] init];
+ activities = [[NSMutableArray alloc] init];
}
return self;
@@ -52,6 +53,14 @@
name:SPTableChangedNotification
object:tableDocumentInstance];
+ [tableInfoScrollView setAlphaValue:1.0f];
+ [activitiesScrollView setAlphaValue:0.0f];
+
+ // [self performSelector:@selector(updateActivities) withObject:nil afterDelay:1.0f];
+
+ [activities addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"ACTIVITIES", @"header for activities pane"), @"name", nil]];
+ [activitiesTable reloadData];
+
[info addObject:NSLocalizedString(@"TABLE INFORMATION", @"header for table info pane")];
[infoTable reloadData];
}
@@ -61,10 +70,23 @@
[[NSNotificationCenter defaultCenter] removeObserver:self];
[info release];
+ [activities release];
[super dealloc];
}
+- (void)updateActivities
+{
+ NSMutableArray *acts = [NSMutableArray array];
+ [acts removeAllObjects];
+ [acts addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"ACTIVITIES", @"header for activities pane"), @"name", nil]];
+ [acts addObjectsFromArray:[tableDocumentInstance runningBASHProcesses]];
+ [acts addObjectsFromArray:[[NSApp delegate] runningBASHProcesses]];
+ [activities setArray:acts];
+ [activitiesTable reloadData];
+ // [self performSelector:@selector(updateActivities) withObject:nil afterDelay:1.0f];
+}
+
/**
* Notification to indicate the table has changed and that the table info requires
* reloading for display. This is called on table changes, and also (with a nil argument)
@@ -251,12 +273,23 @@
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
- return [info count];
+ if(aTableView == infoTable) {
+ return [info count];
+ } else {
+ return [activities count];
+ }
}
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
- return [info objectAtIndex:rowIndex];
+ if(aTableView == infoTable) {
+ return [info objectAtIndex:rowIndex];
+ } else {
+ if(rowIndex > -1 && rowIndex < [activities count])
+ return [NSArrayObjectAtIndex(activities,rowIndex) objectForKey:@"name"];
+ else
+ return @"...";
+ }
}
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
@@ -264,11 +297,26 @@
return (row == 0 ? 25 : [tableView rowHeight]);
}
-
- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(NSInteger)rowIndex
{
- // row 1 and 6 should be editable - ie be able to rename the table and change the auto_increment value.
- return NO;//(rowIndex == 1 || rowIndex == 6 );
+ if(rowIndex == 0) return YES;
+ return NO;
+}
+
+- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
+{
+ if(rowIndex > 0) return NO;
+ if([tableInfoScrollView alphaValue] == 1.0f) {
+ [tableInfoScrollView setAlphaValue:0.0f];
+ [activitiesScrollView setAlphaValue:1.0f];
+ } else {
+ [tableInfoScrollView setAlphaValue:1.0f];
+ [activitiesScrollView setAlphaValue:0.0f];
+ }
+ [infoTable deselectAll:nil];
+ [activitiesTable deselectAll:nil];
+ [self updateActivities];
+ return NO;
}
- (BOOL)tableView:(NSTableView *)aTableView isGroupRow:(NSInteger)row
@@ -279,13 +327,15 @@
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
- if ((rowIndex > 0) && [[aTableColumn identifier] isEqualToString:@"info"]) {
- [(ImageAndTextCell*)aCell setImage:[NSImage imageNamed:@"table-property"]];
- [(ImageAndTextCell*)aCell setIndentationLevel:1];
- [(ImageAndTextCell*)aCell setDrawsBackground:NO];
- } else {
- [(ImageAndTextCell*)aCell setImage:nil];
- [(ImageAndTextCell*)aCell setIndentationLevel:0];
+ if(aTableView == infoTable) {
+ if ((rowIndex > 0) && [[aTableColumn identifier] isEqualToString:@"info"]) {
+ [(ImageAndTextCell*)aCell setImage:[NSImage imageNamed:@"table-property"]];
+ [(ImageAndTextCell*)aCell setIndentationLevel:1];
+ [(ImageAndTextCell*)aCell setDrawsBackground:NO];
+ } else {
+ [(ImageAndTextCell*)aCell setImage:nil];
+ [(ImageAndTextCell*)aCell setIndentationLevel:0];
+ }
}
}
diff --git a/Source/SPTextView.m b/Source/SPTextView.m
index c458e7b1..85d2623a 100644
--- a/Source/SPTextView.m
+++ b/Source/SPTextView.m
@@ -1718,7 +1718,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
NSString *cmdResult = [[theHintString substringWithRange:cmdRange] runBashCommandWithEnvironment:nil atCurrentDirectoryPath:nil error:&err];
if(err == nil) {
[theHintString replaceCharactersInRange:tagRange withString:cmdResult];
- } else {
+ } else if([err code] != 9) { // Suppress an error message if command was killed
NSString *errorMessage = [err localizedDescription];
SPBeginAlertSheet(NSLocalizedString(@"BASH Error", @"bash error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil,
[NSString stringWithFormat:@"%@ “%@”:\n%@", NSLocalizedString(@"Error for", @"error for message"), [theHintString substringWithRange:cmdRange], errorMessage]);
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m
index f75505df..e613dac1 100644
--- a/Source/SPTextViewAdditions.m
+++ b/Source/SPTextViewAdditions.m
@@ -667,7 +667,7 @@
}
}
- } else {
+ } else if([err code] != 9) { // Suppress an error message if command was killed
NSString *errorMessage = [err localizedDescription];
SPBeginAlertSheet(NSLocalizedString(@"BASH Error", @"bash error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil,
[NSString stringWithFormat:@"%@ “%@”:\n%@", NSLocalizedString(@"Error for", @"error for message"), [cmdData objectForKey:@"name"], errorMessage]);