This repository was archived by the owner on Jun 3, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -377,10 +377,9 @@ - (UIImage *)drawRect:(CGRect)rect;
377
377
{
378
378
CGContextRef context = UIGraphicsGetCurrentContext ();
379
379
if (_isCompositingChild) {
380
- [self drawTextWithContext: context bounds: rect padding: _padding view: nil ];
380
+ [self drawTextWithContext: context bounds: rect padding: _padding];
381
381
} else {
382
- WXTextView *textView = (WXTextView *)_view;
383
- [self drawTextWithContext: context bounds: rect padding: _padding view: textView];
382
+ [self drawTextWithContext: context bounds: rect padding: _padding];
384
383
}
385
384
386
385
return nil ;
@@ -741,7 +740,7 @@ - (void)_updateAttributesOnComponentThread:(NSDictionary *)attributes
741
740
[self syncTextStorageForView ];
742
741
}
743
742
744
- - (void )drawTextWithContext : (CGContextRef)context bounds : (CGRect)bounds padding : (UIEdgeInsets)padding view : (WXTextView *) view
743
+ - (void )drawTextWithContext : (CGContextRef)context bounds : (CGRect)bounds padding : (UIEdgeInsets)padding
745
744
{
746
745
if (bounds.size .width <= 0 || bounds.size .height <= 0 ) {
747
746
return ;
Original file line number Diff line number Diff line change @@ -105,19 +105,26 @@ - (void)didFinishDrawingLayer:(BOOL)success
105
105
106
106
- (WXDisplayBlock)_displayBlock
107
107
{
108
+ __weak WXComponent* wself = self;
108
109
WXDisplayBlock displayBlock = ^UIImage *(CGRect bounds, BOOL (^isCancelled)(void )) {
109
110
if (isCancelled ()) {
110
111
return nil ;
111
112
}
112
113
113
- UIGraphicsBeginImageContextWithOptions (bounds.size , [self _bitmapOpaqueWithSize: bounds.size] , 0.0 );
114
- UIImage *image = [self drawRect: bounds];
115
- if (!image) {
116
- image = UIGraphicsGetImageFromCurrentImageContext ();
114
+ __strong WXComponent* sself = wself;
115
+ if (sself) {
116
+ UIGraphicsBeginImageContextWithOptions (bounds.size , [sself _bitmapOpaqueWithSize: bounds.size] , 0.0 );
117
+ UIImage *image = [sself drawRect: bounds];
118
+ if (!image) {
119
+ image = UIGraphicsGetImageFromCurrentImageContext ();
120
+ }
121
+ UIGraphicsEndImageContext ();
122
+
123
+ return image;
124
+ }
125
+ else {
126
+ return nil ;
117
127
}
118
- UIGraphicsEndImageContext ();
119
-
120
- return image;
121
128
};
122
129
123
130
return displayBlock;
You can’t perform that action at this time.
0 commit comments