Merge branch 'fix-display-none' into bugfix/278-memory-leak-issue

This commit is contained in:
Mikael Sand
2018-03-18 23:17:56 +02:00
5 changed files with 43 additions and 5 deletions
+2
View File
@@ -8,11 +8,13 @@
#import <Foundation/Foundation.h>
#import <React/RCTBridge.h>
#import "RNSVGRenderable.h"
#import "RNSVGVBMOS.h"
@interface RNSVGImage : RNSVGRenderable
@property (nonatomic, weak) RCTBridge *bridge;
@property (nonatomic, assign) id src;
@property (nonatomic, strong) NSString* x;
@property (nonatomic, strong) NSString* y;
+17 -1
View File
@@ -9,6 +9,9 @@
#import "RNSVGImage.h"
#import "RCTConvert+RNSVG.h"
#import <React/RCTImageSource.h>
#import <React/RCTImageView.h>
#import <React/RCTImageLoader.h>
#import <React/RCTImageViewManager.h>
#import <React/RCTLog.h>
#import "RNSVGViewBox.h"
@@ -16,6 +19,7 @@
{
CGImageRef _image;
CGSize _imageSize;
RCTImageLoaderCancellationBlock _reloadImageCancellationBlock;
}
- (void)setSrc:(id)src
@@ -32,7 +36,19 @@
} else {
_imageSize = CGSizeMake(CGImageGetWidth(_image), CGImageGetHeight(_image));
}
[self invalidate];
RCTImageLoaderCancellationBlock previousCancellationBlock = _reloadImageCancellationBlock;
if (previousCancellationBlock) {
previousCancellationBlock();
_reloadImageCancellationBlock = nil;
}
_reloadImageCancellationBlock = [self.bridge.imageLoader loadImageWithURLRequest:[RCTConvert NSURLRequest:src] callback:^(NSError *error, UIImage *image) {
dispatch_async(dispatch_get_main_queue(), ^{
_image = CGImageRetain(image.CGImage);
[self invalidate];
});
}];
}
- (void)setX:(NSString *)x
+10
View File
@@ -20,6 +20,16 @@
CGAffineTransform _viewBoxTransform;
}
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
// This is necessary to ensure that [self setNeedsDisplay] actually triggers
// a redraw when our parent transitions between hidden and visible.
self.contentMode = UIViewContentModeRedraw;
}
return self;
}
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex
{
[super insertReactSubview:subview atIndex:atIndex];