Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Fix text crash #2442

Merged
merged 2 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ios/sdk/WeexSDK/Sources/Component/WXTextComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,9 @@ - (UIImage *)drawRect:(CGRect)rect;
{
CGContextRef context = UIGraphicsGetCurrentContext();
if (_isCompositingChild) {
[self drawTextWithContext:context bounds:rect padding:_padding view:nil];
[self drawTextWithContext:context bounds:rect padding:_padding];
} else {
WXTextView *textView = (WXTextView *)_view;
[self drawTextWithContext:context bounds:rect padding:_padding view:textView];
[self drawTextWithContext:context bounds:rect padding:_padding];
}

return nil;
Expand Down Expand Up @@ -741,7 +740,7 @@ - (void)_updateAttributesOnComponentThread:(NSDictionary *)attributes
[self syncTextStorageForView];
}

- (void)drawTextWithContext:(CGContextRef)context bounds:(CGRect)bounds padding:(UIEdgeInsets)padding view:(WXTextView *)view
- (void)drawTextWithContext:(CGContextRef)context bounds:(CGRect)bounds padding:(UIEdgeInsets)padding
{
if (bounds.size.width <= 0 || bounds.size.height <= 0) {
return;
Expand Down
21 changes: 14 additions & 7 deletions ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,26 @@ - (void)didFinishDrawingLayer:(BOOL)success

- (WXDisplayBlock)_displayBlock
{
__weak WXComponent* wself = self;
WXDisplayBlock displayBlock = ^UIImage *(CGRect bounds, BOOL(^isCancelled)(void)) {
if (isCancelled()) {
return nil;
}

UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size] , 0.0);
UIImage *image = [self drawRect:bounds];
if (!image) {
image = UIGraphicsGetImageFromCurrentImageContext();
__strong WXComponent* sself = wself;
if (sself) {
UIGraphicsBeginImageContextWithOptions(bounds.size, [sself _bitmapOpaqueWithSize:bounds.size] , 0.0);
UIImage *image = [sself drawRect:bounds];
if (!image) {
image = UIGraphicsGetImageFromCurrentImageContext();
}
UIGraphicsEndImageContext();

return image;
}
else {
return nil;
}
UIGraphicsEndImageContext();

return image;
};

return displayBlock;
Expand Down