Skip to content

Commit

Permalink
fix HBPackageNameHeaderCell crash when package info isn't found
Browse files Browse the repository at this point in the history
  • Loading branch information
kirb committed Mar 7, 2015
1 parent 4e43919 commit 3757efa
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions prefs/HBPackageNameHeaderCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ - (CGFloat)preferredHeightForWidth:(CGFloat)width {
- (void)updateData {
[self _retrievePackageDetails];

if (![self.textLabel respondsToSelector:@selector(setAttributedText:)]) { // starting to realise the features we take for granted these days...
if ([_packageDetails.allValues containsObject:@""]) {
// i hate pirate repos
return;
}

if (![self.textLabel respondsToSelector:@selector(setAttributedText:)]) {
// starting to realise the features we take for granted these days...
self.textLabel.text = [NSString stringWithFormat:@"%@%@%@", _packageDetails[kHBDebianControlFileNameKey], _showVersion ? @" " : @"", _showVersion ? _packageDetails[kHBDebianControlFileVersionKey] : @""];
return;
}
Expand Down Expand Up @@ -154,11 +160,12 @@ - (void)_retrievePackageDetails {
NSArray *packageData = [HBOutputForShellCommand([NSString stringWithFormat:@"/usr/bin/dpkg-query -f '${Name}\n==libcephei-divider==\n${Version}\n==libcephei-divider==\n${Author}' -W '%@'", identifier]) componentsSeparatedByString:@"\n==libcephei-divider==\n"];

[_packageDetails release];

_packageDetails = [@{
kHBDebianControlFilePackageKey: identifier,
kHBDebianControlFileNameKey: packageData[0],
kHBDebianControlFileVersionKey: packageData[1],
kHBDebianControlFileAuthorKey: packageData[2],
kHBDebianControlFileNameKey: packageData[0] ?: @"",
kHBDebianControlFileVersionKey: packageData[1] ?: @"",
kHBDebianControlFileAuthorKey: packageData[2] ?: @"",
} retain];
}

Expand Down

0 comments on commit 3757efa

Please sign in to comment.