From 2cfbb0144e9fae814267153e2c18cc9bc0634f14 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 4 Jun 2018 18:17:05 -0400 Subject: [PATCH] Fixed segfaults. Now to fix logic errors. (Technically one of the two changes here is a logic error too.) --- darwin/tablecolumn.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/darwin/tablecolumn.m b/darwin/tablecolumn.m index fe71c79e..95217c13 100644 --- a/darwin/tablecolumn.m +++ b/darwin/tablecolumn.m @@ -154,6 +154,8 @@ struct textColumnCreateParams { self->iv = nil; // TODO rename to makeImageView if (p->makeImage) { + self->imageModelColumn = p->imageModelColumn; + self->iv = [[NSImageView alloc] initWithFrame:NSZeroRect]; [self->iv setImageFrameStyle:NSImageFrameNone]; [self->iv setImageAlignment:NSImageAlignCenter]; @@ -173,6 +175,9 @@ struct textColumnCreateParams { self->cb = nil; if (p->makeCheckbox) { + self->checkboxModelColumn = p->checkboxModelColumn; + self->checkboxEditableColumn = p->checkboxEditableColumn; + self->cb = [[NSButton alloc] initWithFrame:NSZeroRect]; [self->cb setTitle:@""]; [self->cb setButtonType:NSSwitchButton]; @@ -258,9 +263,12 @@ struct textColumnCreateParams { double r, g, b, a; data = (*(self->m->mh->CellValue))(self->m->mh, self->m, row, self->textParams.ColorModelColumn); - uiTableDataColor(data, &r, &g, &b, &a); - uiFreeTableData(data); - color = [NSColor colorWithSRGBRed:r green:g blue:b alpha:a]; + // TODO document this is allowed + if (data != NULL) { + uiTableDataColor(data, &r, &g, &b, &a); + uiFreeTableData(data); + color = [NSColor colorWithSRGBRed:r green:g blue:b alpha:a]; + } } if (color == nil) color = [NSColor controlTextColor];