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
AlignTrailingComments: true
AlignConsecutiveAssignments: true
AllowShortIfStatementsOnASingleLine: false
BreakBeforeBraces: Attach
BasedOnStyle: WebKit
AllowShortFunctionsOnASingleLine: false
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 120
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
IndentCaseLabels: true
MaxEmptyLinesToKeep: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true

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

@ -55,13 +55,25 @@ NSString *const TSAttachementsRelationshipEdgeName = @"TSAttachmentEdge";
return self;
}
- (BOOL)hasAttachments {
- (BOOL)hasAttachments
{
return self.attachments ? (self.attachments.count > 0) : false;
}
- (NSString *)description {
- (NSString *)debugDescription
{
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];
if (attachment) {
return attachment.description;

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

Loading…
Cancel
Save