Add code to safeguard against crash when NSMatrix has no cells or the prototype is nil

This commit is contained in:
Gregory John Casamento 2021-04-21 18:14:56 -04:00
parent eb0b0bfbe1
commit 27e6f6b309
4 changed files with 26 additions and 14 deletions

View file

@ -757,8 +757,15 @@ static NSImage *fileImage = nil;
else if ([anObject isKindOfClass: [NSMatrix class]])
{
// add all of the cells....
[self attachObjects: [anObject cells] toParent: anObject];
[self attachObject: [anObject prototype] toParent: anObject];
if ([[anObject cells] count] > 0) // && [anObject prototype] != nil)
{
[self attachObjects: [anObject cells] toParent: anObject];
}
if ([anObject prototype] != nil)
{
[self attachObject: [anObject prototype] toParent: anObject];
}
}
/*
* If it's a simple NSView, add it and all of it's subviews.

View file

@ -519,6 +519,8 @@ NSComparisonResult _sortViews(id view1, id view2, void *context)
NSCell *cell = [editedObject cell];
NSRect rect = [editedObject frame];
NSView *superview = [s superview];
NSLog(@"cell = %@", cell);
// Create the matrix
matrix = [[NSMatrix alloc] initWithFrame: rect

View file

@ -150,19 +150,22 @@ NSUInteger colsStepperValue;
NSInteger tag;
NSString *title;
int c;
for (c = 0; c < [object numberOfColumns]; c++)
if ([object prototype] != nil)
{
int r;
for (r = 0; r < [object numberOfRows]; r++)
for (c = 0; c < [object numberOfColumns]; c++)
{
cell = [object cellAtRow: r column: c];
tag = [cell tag];
title = [cell title];
cell = [[object prototype] copy];
[cell setTag: tag];
[cell setTitle: title];
[object putCell:cell atRow:r column:c];
[cell release];
int r;
for (r = 0; r < [object numberOfRows]; r++)
{
cell = [object cellAtRow: r column: c];
tag = [cell tag];
title = [cell title];
cell = [[object prototype] copy];
[cell setTag: tag];
[cell setTitle: title];
[object putCell:cell atRow:r column:c];
[cell release];
}
}
}
[object deselectAllCells];

View file

@ -1,6 +1,6 @@
{
"## Comment" = "Do NOT change this file, Gorm maintains it";
GormMatrixInspector = {
GormMatrixAttributesInspector = {
Actions = (
);
Outlets = (