From e93d9df70e29e53c4588a6d49bf3a056ac56e9db Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 29 Oct 2010 20:06:44 +0000 Subject: =?UTF-8?q?=E2=80=A2=20convert=20the=20Field=20Editor=20Sheet=20in?= =?UTF-8?q?to=20a=20document-modal=20sheet,=20i.e.=20now=20the=20sheet=20?= =?UTF-8?q?=20doesn't=20block=20the=20entire=20app=20-=20fixed=20various?= =?UTF-8?q?=20layout=20issues=20-=20fixed=20some=20tiny=20memory=20leaks?= =?UTF-8?q?=20=E2=80=A2=20fixed=20tiny=20memory=20leak=20in=20MCPStreaming?= =?UTF-8?q?Result?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPTableContent.m | 96 ++++++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 40 deletions(-) (limited to 'Source/SPTableContent.m') diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index bab3cf0d..0ee639c8 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -2873,7 +2873,7 @@ * Show Error sheet (can be called from inside of a endSheet selector) * via [self performSelector:@selector(showErrorSheetWithTitle:) withObject: afterDelay:] */ --(void)showErrorSheetWith:(id)error +- (void)showErrorSheetWith:(id)error { // error := first object is the title , second the message, only one button OK SPBeginAlertSheet([error objectAtIndex:0], NSLocalizedString(@"OK", @"OK button"), @@ -2881,6 +2881,45 @@ [error objectAtIndex:1]); } +- (void)processFieldEditorResult:(id)data contextInfo:(NSDictionary*)contextInfo +{ + + if (data && contextInfo) { + NSUInteger row = [[contextInfo objectForKey:@"row"] integerValue]; + NSUInteger column = [[contextInfo objectForKey:@"column"] integerValue]; + BOOL isFieldEditable = ([contextInfo objectForKey:@"isFieldEditable"]) ? YES : NO; + if (!isEditingRow && [tablesListInstance tableType] != SPTableTypeView) { + [oldRow setArray:[tableValues rowContentsAtIndex:row]]; + isEditingRow = YES; + currentlyEditingRow = row; + } + + if ([data isKindOfClass:[NSString class]] + && [data isEqualToString:[prefs objectForKey:SPNullValue]] + && [[NSArrayObjectAtIndex(dataColumns, column) objectForKey:@"null"] boolValue]) + { + data = [[NSNull null] retain]; + } + if(isFieldEditable) { + if([tablesListInstance tableType] == SPTableTypeView) { + // since in a view we're editing a field rather than a row + isEditingRow = NO; + // update the field and refresh the table + [self tableView:tableContentView setObjectValue:[[data copy] autorelease] forTableColumn:[tableContentView tableColumnWithIdentifier:[contextInfo objectForKey:@"column"]] row:row]; + } else { + [tableValues replaceObjectInRow:row column:column withObject:[[data copy] autorelease]]; + } + } + } + + if(fieldEditor) { + [fieldEditor release]; + fieldEditor = nil; + } + + [[tableDocumentInstance parentWindow] makeFirstResponder:tableContentView]; +} + #pragma mark - #pragma mark Filter Table @@ -3899,7 +3938,8 @@ } } - SPFieldEditorController *fieldEditor = [[SPFieldEditorController alloc] init]; + if(fieldEditor) [fieldEditor release], fieldEditor = nil; + fieldEditor = [[SPFieldEditorController alloc] init]; [fieldEditor setTextMaxLength:fieldLength]; [fieldEditor setFieldType:(fieldType==nil) ? @"" : fieldType]; @@ -3910,44 +3950,18 @@ if ([cellValue isNSNull]) cellValue = [NSString stringWithString:[prefs objectForKey:SPNullValue]]; - id editData = [[fieldEditor editWithObject:cellValue - fieldName:[[aTableColumn headerCell] stringValue] - usingEncoding:[mySQLConnection stringEncoding] - isObjectBlob:isBlob - isEditable:isFieldEditable - withWindow:[tableDocumentInstance parentWindow]] retain]; - - if (editData) { - if (!isEditingRow && [tablesListInstance tableType] != SPTableTypeView) { - [oldRow setArray:[tableValues rowContentsAtIndex:rowIndex]]; - isEditingRow = YES; - currentlyEditingRow = rowIndex; - } - - if ([editData isKindOfClass:[NSString class]] - && [editData isEqualToString:[prefs objectForKey:SPNullValue]] - && [[NSArrayObjectAtIndex(dataColumns, [[aTableColumn identifier] integerValue]) objectForKey:@"null"] boolValue]) - { - [editData release]; - editData = [[NSNull null] retain]; - } - if(isFieldEditable) { - if([tablesListInstance tableType] == SPTableTypeView) { - // since in a view we're editing a field rather than a row - isEditingRow = NO; - // update the field and refresh the table - [self tableView:aTableView setObjectValue:[[editData copy] autorelease] forTableColumn:aTableColumn row:rowIndex]; - } else { - [tableValues replaceObjectInRow:rowIndex column:[[aTableColumn identifier] integerValue] withObject:[[editData copy] autorelease]]; - } - } - } - - [fieldEditor release]; - - if (editData) [editData release]; - - [[tableDocumentInstance parentWindow] makeFirstResponder:tableContentView]; + [fieldEditor editWithObject:cellValue + fieldName:[[aTableColumn headerCell] stringValue] + usingEncoding:[mySQLConnection stringEncoding] + isObjectBlob:isBlob + isEditable:isFieldEditable + withWindow:[tableDocumentInstance parentWindow] + sender:self + contextInfo:[NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithInteger:rowIndex], @"row", + [aTableColumn identifier], @"column", + [NSNumber numberWithBool:isFieldEditable], @"isFieldEditable", + nil]]; return NO; } @@ -4466,6 +4480,8 @@ [NSObject cancelPreviousPerformRequestsWithTarget:self]; [NSObject cancelPreviousPerformRequestsWithTarget:tableContentView]; + if(fieldEditor) [fieldEditor release], fieldEditor = nil; + [self clearTableLoadTimer]; [tableValues release]; pthread_mutex_destroy(&tableValuesLock); -- cgit v1.2.3