Skip to content

Commit 0c87d94

Browse files
committed
Fix some warnings
1 parent 401a94f commit 0c87d94

File tree

5 files changed

+35
-26
lines changed

5 files changed

+35
-26
lines changed

Classes/GlobalStateExplorers/FileBrowser/FLEXFileBrowserController.m

+11-5
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,17 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
266266
if ([pathExtension isEqualToString:@"json"]) {
267267
prettyString = [FLEXUtility prettyJSONStringFromData:fileData];
268268
} else {
269-
// Regardless of file extension...
270-
271-
// Try to decode an archived object regardless of file extension
272-
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:fileData error:nil];
273-
unarchiver.requiresSecureCoding = NO;
269+
// Try to decode an archived object, regardless of file extension
270+
NSKeyedUnarchiver *unarchiver = ({
271+
NSKeyedUnarchiver *obj = nil;
272+
if (@available(iOS 12.0, *)) {
273+
obj = [[NSKeyedUnarchiver alloc] initForReadingFromData:fileData error:nil];
274+
} else {
275+
obj = [[NSKeyedUnarchiver alloc] initForReadingWithData:fileData];
276+
}
277+
obj.requiresSecureCoding = NO;
278+
obj;
279+
});
274280
id object = [unarchiver decodeObjectForKey:NSKeyedArchiveRootObjectKey];
275281

276282
// Try to decode other things instead

Classes/Network/PonyDebugger/FLEXNetworkObserver.m

+20-16
Original file line numberDiff line numberDiff line change
@@ -667,18 +667,20 @@ + (void)swizzleResumeSelector:(SEL)selector forClass:(Class)class {
667667
Method originalResume = class_getInstanceMethod(class, selector);
668668
IMP implementation = imp_implementationWithBlock(^(NSURLSessionTask *slf) {
669669

670-
// AVAggregateAssetDownloadTask deeply does not like to be looked at. Accessing -currentRequest or
671-
// -originalRequest will crash. Do not try to observe these. https://github.com/FLEXTool/FLEX/issues/276
672-
if (![slf isKindOfClass:[AVAggregateAssetDownloadTask class]]) {
673-
// iOS's internal HTTP parser finalization code is mysteriously not thread safe,
674-
// invoking it asynchronously has a chance to cause a `double free` crash.
675-
// This line below will ask for HTTPBody synchronously, make the HTTPParser
676-
// parse the request, and cache them in advance. After that the HTTPParser
677-
// will be finalized. Make sure other threads inspecting the request
678-
// won't trigger a race to finalize the parser.
679-
[slf.currentRequest HTTPBody];
680-
681-
[FLEXNetworkObserver.sharedObserver URLSessionTaskWillResume:slf];
670+
if (@available(iOS 11.0, *)) {
671+
// AVAggregateAssetDownloadTask deeply does not like to be looked at. Accessing -currentRequest or
672+
// -originalRequest will crash. Do not try to observe these. https://github.com/FLEXTool/FLEX/issues/276
673+
if (![slf isKindOfClass:[AVAggregateAssetDownloadTask class]]) {
674+
// iOS's internal HTTP parser finalization code is mysteriously not thread safe,
675+
// invoking it asynchronously has a chance to cause a `double free` crash.
676+
// This line below will ask for HTTPBody synchronously, make the HTTPParser
677+
// parse the request, and cache them in advance. After that the HTTPParser
678+
// will be finalized. Make sure other threads inspecting the request
679+
// won't trigger a race to finalize the parser.
680+
[slf.currentRequest HTTPBody];
681+
682+
[FLEXNetworkObserver.sharedObserver URLSessionTaskWillResume:slf];
683+
}
682684
}
683685

684686
((void(*)(id, SEL))objc_msgSend)(
@@ -1985,10 +1987,12 @@ - (void)URLSession:(NSURLSession *)session
19851987
}
19861988

19871989
- (void)URLSessionTaskWillResume:(NSURLSessionTask *)task {
1988-
// AVAggregateAssetDownloadTask deeply does not like to be looked at. Accessing -currentRequest or
1989-
// -originalRequest will crash. Do not try to observe these. https://github.com/FLEXTool/FLEX/issues/276
1990-
if ([task isKindOfClass:[AVAggregateAssetDownloadTask class]]) {
1991-
return;
1990+
if (@available(iOS 11.0, *)) {
1991+
// AVAggregateAssetDownloadTask deeply does not like to be looked at. Accessing -currentRequest or
1992+
// -originalRequest will crash. Do not try to observe these. https://github.com/FLEXTool/FLEX/issues/276
1993+
if ([task isKindOfClass:[AVAggregateAssetDownloadTask class]]) {
1994+
return;
1995+
}
19921996
}
19931997

19941998
// Since resume can be called multiple times on the same task, only treat the first resume as

Classes/Utility/FLEXUtility.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#import <objc/runtime.h>
1515
#import <zlib.h>
1616

17-
BOOL FLEXConstructorsShouldRun() {
17+
BOOL FLEXConstructorsShouldRun(void) {
1818
#if FLEX_DISABLE_CTORS
1919
return NO;
2020
#else

Classes/Utility/Runtime/Objc/FLEXRuntimeSafety.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
(class_getInstanceVariable([cls class], name) ?: (void *)kCFNull)
2020

2121
__attribute__((constructor))
22-
static void FLEXRuntimeSafteyInit() {
22+
static void FLEXRuntimeSafteyInit(void) {
2323
FLEXKnownUnsafeClasses = CFSetCreate(
2424
kCFAllocatorDefault,
2525
(const void **)(uintptr_t)FLEXKnownUnsafeClassList(),
@@ -39,7 +39,7 @@ static void FLEXRuntimeSafteyInit() {
3939
);
4040
}
4141

42-
const Class * FLEXKnownUnsafeClassList() {
42+
const Class * FLEXKnownUnsafeClassList(void) {
4343
if (!_UnsafeClasses) {
4444
const Class ignored[] = {
4545
FLEXClassPointerOrCFNull(@"__ARCLite__"),
@@ -74,7 +74,7 @@ static void FLEXRuntimeSafteyInit() {
7474
return _UnsafeClasses;
7575
}
7676

77-
NSSet * FLEXKnownUnsafeClassNames() {
77+
NSSet * FLEXKnownUnsafeClassNames(void) {
7878
static NSSet *set = nil;
7979
if (!set) {
8080
NSArray *ignored = @[

Classes/ViewHierarchy/SnapshotExplorer/FHSView.m

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ + (UIImage *)drawView:(UIView *)view {
9393
}
9494

9595
CGSize size = view.bounds.size;
96-
CGRect bounds = view.bounds;
9796
CGFloat minUnit = 1.f / UIScreen.mainScreen.scale;
9897

9998
// Every drawn view must not have 0 width or height

0 commit comments

Comments
 (0)