Skip to content

Commit 5f3c003

Browse files
committed
Fix a bug that could cause items in the favorite list to be color-labeled when they don't have a label assigned
1 parent fc02994 commit 5f3c003

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Source/SPConnectionControllerDelegate.m

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,38 +147,41 @@ - (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NST
147147

148148
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
149149
{
150-
SPTreeNode *node = (SPTreeNode *)item;
150+
SPTreeNode *node = (SPTreeNode *)item;
151+
SPFavoriteTextFieldCell *favoriteCell = (SPFavoriteTextFieldCell *)cell;
151152

152153
// Draw entries with the small system font by default
153-
[(SPTableTextFieldCell *)cell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
154+
[cell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
154155

155156
// Set an image as appropriate; the quick connect image for that entry, no image for other
156157
// top-level items, the folder image for group nodes, or the database image for other nodes.
157158
if (![[node parentNode] parentNode]) {
158159
if (node == quickConnectItem) {
159160
if ([outlineView rowForItem:item] == [outlineView selectedRow]) {
160-
[(SPTableTextFieldCell *)cell setImage:[NSImage imageNamed:SPQuickConnectImageWhite]];
161+
[favoriteCell setImage:[NSImage imageNamed:SPQuickConnectImageWhite]];
161162
}
162163
else {
163-
[(SPTableTextFieldCell *)cell setImage:[NSImage imageNamed:SPQuickConnectImage]];
164+
[favoriteCell setImage:[NSImage imageNamed:SPQuickConnectImage]];
164165
}
165166
}
166167
else {
167-
[(SPTableTextFieldCell *)cell setImage:nil];
168+
[favoriteCell setImage:nil];
168169
}
170+
[favoriteCell setLabelColor:nil];
169171
}
170172
else {
171173
if ([node isGroup]) {
172-
[(SPTableTextFieldCell *)cell setImage:folderImage];
174+
[favoriteCell setImage:folderImage];
175+
[favoriteCell setLabelColor:nil];
173176
}
174177
else {
175-
[(SPTableTextFieldCell *)cell setImage:[NSImage imageNamed:SPDatabaseImage]];
178+
[favoriteCell setImage:[NSImage imageNamed:SPDatabaseImage]];
176179
NSColor *bgColor = nil;
177180
NSNumber *colorIndexObj = [[[node representedObject] nodeFavorite] objectForKey:SPFavoriteColorIndexKey];
178181
if(colorIndexObj != nil) {
179182
bgColor = [[SPFavoriteColorSupport sharedInstance] colorForIndex:[colorIndexObj integerValue]];
180183
}
181-
[(SPFavoriteTextFieldCell *)cell setLabelColor:bgColor];
184+
[favoriteCell setLabelColor:bgColor];
182185
}
183186
}
184187

Source/SPFavoriteTextFieldCell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ - (id)copyWithZone:(NSZone *)zone
4949
SPFavoriteTextFieldCell *cell = (SPFavoriteTextFieldCell *)[super copyWithZone:zone];
5050

5151
cell->drawsDividerUnderCell = drawsDividerUnderCell;
52-
cell->labelColor = nil; //TODO copying the color sometimes causes a drawing bug
52+
cell->labelColor = [labelColor copyWithZone:zone];
5353

5454
return cell;
5555
}

0 commit comments

Comments
 (0)