Skip to content

Commit

Permalink
Merge branch 'release-1.7.13'
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Nov 6, 2017
2 parents a81237e + c84dac8 commit b33583a
Show file tree
Hide file tree
Showing 29 changed files with 227 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
language: objective-c
osx_image: xcode7
osx_image: xcode8.3

before_install:
- curl -sL https://gist.github.com/henrikhodne/7ac6d02ff9a24a94720c/raw/install_appledoc.sh | sh
Expand Down
22 changes: 16 additions & 6 deletions Core/Source/DTASN1/DTASN1Parser.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ - (id)initWithData:(NSData *)data
_UTCFormatter = [[NSDateFormatter alloc] init];
_UTCFormatter.dateFormat = @"yyMMddHHmmss'Z'";
_UTCFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
_UTCFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];

if (!_dataLength)
{
Expand Down Expand Up @@ -336,10 +337,16 @@ - (BOOL)_parseValueWithTag:(NSUInteger)tag dataRange:(NSRange)dataRange
{
if (_delegateFlags.delegateSupportsString)
{
uint8_t *buffer = malloc(dataRange.length);
[_data getBytes:buffer range:dataRange];
NSString *string = @"";
uint8_t *buffer = NULL;

NSString *string = [[NSString alloc] initWithBytesNoCopy:buffer length:dataRange.length encoding:NSUTF8StringEncoding freeWhenDone:YES];
if (dataRange.length)
{
buffer = malloc(dataRange.length);
[_data getBytes:buffer range:dataRange];

string = [[NSString alloc] initWithBytesNoCopy:buffer length:dataRange.length encoding:NSUTF8StringEncoding freeWhenDone:YES];
}

// FIXME: This does not properly deal with Latin1 strings, those get simply ignored

Expand All @@ -349,8 +356,11 @@ - (BOOL)_parseValueWithTag:(NSUInteger)tag dataRange:(NSRange)dataRange
}
else
{
free(buffer);
buffer = NULL;
if (buffer)
{
free(buffer);
buffer = NULL;
}
}
}
break;
Expand Down Expand Up @@ -423,7 +433,7 @@ - (BOOL)_parseRange:(NSRange)range
}

// get length
NSUInteger lengthOfLength;
NSUInteger lengthOfLength = 0;
NSUInteger length = [self _parseLengthAtLocation:location lengthOfLength:&lengthOfLength];

// abort if there was a problem with the length
Expand Down
2 changes: 1 addition & 1 deletion Core/Source/DTAsyncFileDeleter/DTAsyncFileDeleter.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ - (void)removeItemAtPath:(NSString *)path
__block UIBackgroundTaskIdentifier backgroundTaskID = UIBackgroundTaskInvalid;

// block to use for timeout as well as completed task
void (^completionBlock)() = ^{
void (^completionBlock)(void) = ^{
[[UIApplication sharedApplication] endBackgroundTask:backgroundTaskID];
backgroundTaskID = UIBackgroundTaskInvalid;
};
Expand Down
17 changes: 17 additions & 0 deletions Core/Source/DTReachability/DTReachability.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,27 @@ - (instancetype) initWithHostname:(NSString *)hostname
{
_observers = [[NSMutableSet alloc] init];
_hostname = hostname;

#if TARGET_OS_IPHONE
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
#endif
}
return self;
}

- (void)applicationDidEnterBackground:(NSNotification *)notification
{
[self _unregisterNetworkReachability];
}

- (void)applicationDidBecomeActive:(NSNotification *)notification
{
[self _registerNetworkReachability];
}



- (void)dealloc
{
[self _unregisterNetworkReachability];
Expand Down
4 changes: 2 additions & 2 deletions Core/Source/DTSQLite/DTSQLiteDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
/**
@param block The block to perform
*/
- (void)performBlock:(void (^)())block;
- (void)performBlock:(void (^)(void))block;

/**
@param block The block to perform
*/
- (void)performBlockAndWait:(void (^)())block;
- (void)performBlockAndWait:(void (^)(void))block;

@end
4 changes: 2 additions & 2 deletions Core/Source/DTSQLite/DTSQLiteDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ - (NSArray *)fetchRowsForQuery:(NSString *)query error:(NSError **)error

#pragma mark - Block Operations

- (void)performBlock:(void (^)())block
- (void)performBlock:(void (^)(void))block
{
[_queue addOperationWithBlock:block];
}

- (void)performBlockAndWait:(void (^)())block
- (void)performBlockAndWait:(void (^)(void))block
{
[_queue addOperationWithBlock:block];
[_queue waitUntilAllOperationsAreFinished];
Expand Down
3 changes: 1 addition & 2 deletions Core/Source/Externals/minizip/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,8 +1170,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
pfile_info->internal_fa = file_info64.internal_fa;
pfile_info->external_fa = file_info64.external_fa;

pfile_info->tmu_date = file_info64.tmu_date,

pfile_info->tmu_date = file_info64.tmu_date;

pfile_info->compressed_size = (uLong)file_info64.compressed_size;
pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
Expand Down
4 changes: 2 additions & 2 deletions Core/Source/Runtime/DTObjectBlockExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
Convenience method to create a block executor with a deallocation block
@param block The block to execute when the created receiver is being deallocated
*/
+ (id)blockExecutorWithDeallocBlock:(void(^)())block;
+ (id)blockExecutorWithDeallocBlock:(void(^)(void))block;

/**
Block to execute when dealloc of the receiver is called
*/
@property (nonatomic, copy) void (^deallocBlock)();
@property (nonatomic, copy) void (^deallocBlock)(void);

@end
2 changes: 1 addition & 1 deletion Core/Source/Runtime/DTObjectBlockExecutor.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@implementation DTObjectBlockExecutor

+ (id)blockExecutorWithDeallocBlock:(void(^)())block
+ (id)blockExecutorWithDeallocBlock:(void(^)(void))block
{
DTObjectBlockExecutor *executor = [[DTObjectBlockExecutor alloc] init];
executor.deallocBlock = block; // copy
Expand Down
2 changes: 1 addition & 1 deletion Core/Source/Runtime/NSObject+DTRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Adds a block to be executed as soon as the receiver's memory is deallocated
@param block The block to execute when the receiver is being deallocated
*/
- (void)addDeallocBlock:(void(^)())block;
- (void)addDeallocBlock:(void(^)(void))block;

/**
Adds a new instance method to a class. All instances of this class will have this method.
Expand Down
2 changes: 1 addition & 1 deletion Core/Source/Runtime/NSObject+DTRuntime.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ @implementation NSObject (DTRuntime)

#pragma mark - Blocks

- (void)addDeallocBlock:(void(^)())block
- (void)addDeallocBlock:(void(^)(void))block
{
// don't accept NULL block
NSParameterAssert(block);
Expand Down
5 changes: 3 additions & 2 deletions Core/Source/iOS/DTProgressHUD/DTProgressHUDWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "DTProgressHUDWindow.h"
#import "DTProgressHUD.h"
#import "UIScreen+DTFoundation.h"

#define DegreesToRadians(degrees) (degrees * M_PI / 180)

Expand Down Expand Up @@ -60,7 +61,7 @@ - (instancetype)initWithProgressHUD:(DTProgressHUD *)progressHUD
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarDidChangeFrame:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];

// set initial transform
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
UIInterfaceOrientation orientation = [[UIScreen mainScreen] orientation];
[self setTransform:_transformForInterfaceOrientation(orientation)];
}
return self;
Expand All @@ -75,7 +76,7 @@ - (void)dealloc

- (void)statusBarDidChangeFrame:(NSNotification *)notification
{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
UIInterfaceOrientation orientation = [[UIScreen mainScreen] orientation];
[self setTransform:_transformForInterfaceOrientation(orientation)];
}

Expand Down
5 changes: 5 additions & 0 deletions Core/Source/iOS/DTTiledLayerWithoutFade.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ + (CFTimeInterval)fadeDuration
return 0;
}

+ (BOOL)shouldDrawOnMainThread
{
return YES;
}

@end
18 changes: 12 additions & 6 deletions Core/Source/iOS/UIImage+DTFoundation.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ + (UIImage *)imageWithContentsOfURL:(NSURL *)URL cachePolicy:(NSURLRequestCacheP
NSCachedURLResponse *cacheResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request];

__block NSData *data;
__block NSError *internalError;

if (cacheResponse)
{
Expand All @@ -89,12 +90,12 @@ + (UIImage *)imageWithContentsOfURL:(NSURL *)URL cachePolicy:(NSURLRequestCacheP
#else
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);

[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *responseData, NSURLResponse *response, NSError *responseError) {
data = responseData;
*error = responseError;
dispatch_semaphore_signal(semaphore);
}];
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *responseData, NSURLResponse *response, NSError *responseError) {
data = responseData;
internalError = responseError;
dispatch_semaphore_signal(semaphore);
}] resume];

dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
#endif
Expand All @@ -105,6 +106,11 @@ + (UIImage *)imageWithContentsOfURL:(NSURL *)URL cachePolicy:(NSURLRequestCacheP
return nil;
}

if (error)
{
*error = internalError;
}

UIImage *image = [UIImage imageWithData:data];
return image;
}
Expand Down
15 changes: 15 additions & 0 deletions Core/Source/iOS/UIScreen+DTFoundation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// UIScreen+DTFoundation.h
// DTFoundation
//
// Created by Johannes Marbach on 16.10.17.
// Copyright © 2017 Cocoanetics. All rights reserved.
//

/** DTFoundation enhancements for `UIView` */

@interface UIScreen (DTFoundation)

- (UIInterfaceOrientation)orientation;

@end
28 changes: 28 additions & 0 deletions Core/Source/iOS/UIScreen+DTFoundation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// UIScreen+DTFoundation.m
// DTFoundation
//
// Created by Johannes Marbach on 16.10.17.
// Copyright © 2017 Cocoanetics. All rights reserved.
//

#import "UIScreen+DTFoundation.h"

@implementation UIScreen (DTFoundation)

- (UIInterfaceOrientation)orientation {
CGPoint point = [self.coordinateSpace convertPoint:CGPointZero toCoordinateSpace:self.fixedCoordinateSpace];
if (point.x == 0 && point.y == 0) {
return UIInterfaceOrientationPortrait;
} else if (point.x != 0 && point.y != 0) {
return UIInterfaceOrientationPortraitUpsideDown;
} else if (point.x == 0 && point.y != 0) {
return UIInterfaceOrientationLandscapeLeft;
} else if (point.x != 0 && point.y == 0) {
return UIInterfaceOrientationLandscapeRight;
} else {
return UIInterfaceOrientationUnknown;
}
}

@end
Loading

0 comments on commit b33583a

Please sign in to comment.