Avoid deadlock while accepting new key (#17)

Using description in log output crashes when the description is a media
message, since printing media description uses a transaction within our
existing transaction.

Instead we'll use a simpler debugDescription for simple text building,
like logging.

// FREEBIE
pull/1/head
Michael Kirk 9 years ago committed by GitHub
parent f537b6f192
commit d66c8bd427

@ -1,14 +1,10 @@
--- ---
BasedOnStyle: Chromium BasedOnStyle: WebKit
AlignTrailingComments: true AllowShortFunctionsOnASingleLine: false
AlignConsecutiveAssignments: true
AllowShortIfStatementsOnASingleLine: false
BreakBeforeBraces: Attach
BinPackArguments: false BinPackArguments: false
BinPackParameters: false BinPackParameters: false
ColumnLimit: 120 ColumnLimit: 120
IndentWidth: 4 IndentCaseLabels: true
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 2 MaxEmptyLinesToKeep: 2
ObjCSpaceAfterProperty: true ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true ObjCSpaceBeforeProtocolList: true

@ -21,7 +21,7 @@
@property (nonatomic, retain) NSDate *lastMessageDate; @property (nonatomic, retain) NSDate *lastMessageDate;
@property (nonatomic, copy) NSString *messageDraft; @property (nonatomic, copy) NSString *messageDraft;
- (TSInteraction *) lastInteraction; - (TSInteraction *)lastInteraction;
@end @end
@ -111,7 +111,7 @@
if (self.lastInteraction == nil) { if (self.lastInteraction == nil) {
return @""; return @"";
} else { } else {
return self.lastInteraction.description; return [self lastInteraction].description;
} }
} }

@ -55,13 +55,25 @@ NSString *const TSAttachementsRelationshipEdgeName = @"TSAttachmentEdge";
return self; return self;
} }
- (BOOL)hasAttachments { - (BOOL)hasAttachments
{
return self.attachments ? (self.attachments.count > 0) : false; return self.attachments ? (self.attachments.count > 0) : false;
} }
- (NSString *)description { - (NSString *)debugDescription
{
if ([self hasAttachments]) { if ([self hasAttachments]) {
NSString *attachmentId = self.attachments[0]; NSString *attachmentId = self.attachments[0];
return [NSString stringWithFormat:@"Media Message with attachmentId:%@", attachmentId];
} else {
return [NSString stringWithFormat:@"Message with body:%@", self.body];
}
}
- (NSString *)description
{
if ([self hasAttachments]) {
NSString *attachmentId = self.attachments[0];
TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId]; TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId];
if (attachment) { if (attachment) {
return attachment.description; return attachment.description;

@ -69,7 +69,7 @@
NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) { NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) {
TSInteraction *interaction = (TSInteraction *)object; TSInteraction *interaction = (TSInteraction *)object;
DDLogVerbose(@"Interaction type: %@", interaction.description); DDLogVerbose(@"Interaction type: %@", interaction.debugDescription);
if ([interaction isKindOfClass:[TSInvalidIdentityKeyErrorMessage class]]) { if ([interaction isKindOfClass:[TSInvalidIdentityKeyErrorMessage class]]) {
TSInvalidIdentityKeyErrorMessage *invalidKeyMessage = TSInvalidIdentityKeyErrorMessage *invalidKeyMessage =

Loading…
Cancel
Save