iOS: fix deprecations and leaks
Fixes some deprecations and leaks reported by Xcode Analyzer
This commit is contained in:
parent
9bf5a0b791
commit
f81c6c52fc
|
@ -49,8 +49,10 @@ void _set_keep_screen_on(bool p_enabled);
|
|||
Error _shell_open(String p_uri) {
|
||||
NSString *url = [[NSString alloc] initWithUTF8String:p_uri.utf8().get_data()];
|
||||
|
||||
if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:url]])
|
||||
if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:url]]) {
|
||||
[url release];
|
||||
return ERR_CANT_OPEN;
|
||||
}
|
||||
|
||||
printf("opening url %ls\n", p_uri.c_str());
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
|
||||
|
@ -548,7 +550,7 @@ static int frame_count = 0;
|
|||
// can use that instead? (note that left and right seem swapped)
|
||||
|
||||
switch ([[UIApplication sharedApplication] statusBarOrientation]) {
|
||||
case UIDeviceOrientationLandscapeLeft: {
|
||||
case UIInterfaceOrientationLandscapeLeft: {
|
||||
OSIPhone::get_singleton()->update_gravity(-gravity.y, gravity.x,
|
||||
gravity.z);
|
||||
OSIPhone::get_singleton()->update_accelerometer(
|
||||
|
@ -559,7 +561,7 @@ static int frame_count = 0;
|
|||
OSIPhone::get_singleton()->update_gyroscope(-rotation.y, rotation.x,
|
||||
rotation.z);
|
||||
}; break;
|
||||
case UIDeviceOrientationLandscapeRight: {
|
||||
case UIInterfaceOrientationLandscapeRight: {
|
||||
OSIPhone::get_singleton()->update_gravity(gravity.y, -gravity.x,
|
||||
gravity.z);
|
||||
OSIPhone::get_singleton()->update_accelerometer(
|
||||
|
@ -570,7 +572,7 @@ static int frame_count = 0;
|
|||
OSIPhone::get_singleton()->update_gyroscope(rotation.y, -rotation.x,
|
||||
rotation.z);
|
||||
}; break;
|
||||
case UIDeviceOrientationPortraitUpsideDown: {
|
||||
case UIInterfaceOrientationPortraitUpsideDown: {
|
||||
OSIPhone::get_singleton()->update_gravity(-gravity.x, gravity.y,
|
||||
gravity.z);
|
||||
OSIPhone::get_singleton()->update_accelerometer(
|
||||
|
@ -595,7 +597,7 @@ static int frame_count = 0;
|
|||
};
|
||||
}
|
||||
|
||||
bool quit_request = OSIPhone::get_singleton()->iterate();
|
||||
OSIPhone::get_singleton()->iterate();
|
||||
};
|
||||
|
||||
}; break;
|
||||
|
@ -614,7 +616,6 @@ static int frame_count = 0;
|
|||
|
||||
is_focus_out = false;
|
||||
|
||||
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
|
||||
// disable idle timer
|
||||
// application.idleTimerDisabled = YES;
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
- (void)keyboardOnScreen:(NSNotification *)notification;
|
||||
- (void)keyboardHidden:(NSNotification *)notification;
|
||||
|
||||
@property NSTimeInterval animationInterval;
|
||||
@property(nonatomic, assign) NSTimeInterval animationInterval;
|
||||
@property(nonatomic, assign) BOOL useCADisplayLink;
|
||||
|
||||
@end
|
||||
|
|
|
@ -80,10 +80,12 @@ void _hide_keyboard() {
|
|||
};
|
||||
|
||||
Rect2 _get_ios_window_safe_area(float p_window_width, float p_window_height) {
|
||||
UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, 0, 0);
|
||||
if (_instance != nil && [_instance respondsToSelector:@selector(safeAreaInsets)]) {
|
||||
UIEdgeInsets insets = UIEdgeInsetsZero;
|
||||
|
||||
if (@available(iOS 11.0, *)) {
|
||||
insets = [_instance safeAreaInsets];
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(insets.left < 0 || insets.top < 0 || insets.right < 0 || insets.bottom < 0,
|
||||
Rect2(0, 0, p_window_width, p_window_height));
|
||||
UIEdgeInsets window_insets = UIEdgeInsetsMake(_points_to_pixels(insets.top), _points_to_pixels(insets.left), _points_to_pixels(insets.bottom), _points_to_pixels(insets.right));
|
||||
|
@ -699,7 +701,7 @@ static void clear_touches() {
|
|||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
||||
|
||||
if (object == _instance.avPlayerItem && [keyPath isEqualToString:@"status"]) {
|
||||
if (_instance.avPlayerItem.status == AVPlayerStatusFailed || _instance.avPlayer.status == AVPlayerStatusFailed) {
|
||||
if (_instance.avPlayerItem.status == AVPlayerItemStatusFailed || _instance.avPlayer.status == AVPlayerStatusFailed) {
|
||||
_stop_video();
|
||||
video_found_error = true;
|
||||
}
|
||||
|
|
|
@ -68,17 +68,18 @@ const CGFloat kGLGestureMovementDistance = 0.5;
|
|||
[self.view touchesBegan:delayedTouches withEvent:delayedEvent];
|
||||
}
|
||||
|
||||
[delayedTouches release];
|
||||
delayedTouches = nil;
|
||||
delayedEvent = nil;
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
NSSet *cleared = [self clearTouches:touches phase:UITouchPhaseBegan];
|
||||
NSSet *cleared = [self copyClearedTouches:touches phase:UITouchPhaseBegan];
|
||||
[self delayTouches:cleared andEvent:event];
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
NSSet *cleared = [self clearTouches:touches phase:UITouchPhaseMoved];
|
||||
NSSet *cleared = [self copyClearedTouches:touches phase:UITouchPhaseMoved];
|
||||
|
||||
if (delayTimer) {
|
||||
// We should check if movement was significant enough to fire an event
|
||||
|
@ -95,20 +96,24 @@ const CGFloat kGLGestureMovementDistance = 0.5;
|
|||
if (distance > kGLGestureMovementDistance) {
|
||||
[delayTimer fire];
|
||||
[self.view touchesMoved:cleared withEvent:event];
|
||||
[cleared release];
|
||||
return;
|
||||
}
|
||||
}
|
||||
[cleared release];
|
||||
return;
|
||||
}
|
||||
|
||||
[self.view touchesMoved:cleared withEvent:event];
|
||||
[cleared release];
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
[delayTimer fire];
|
||||
|
||||
NSSet *cleared = [self clearTouches:touches phase:UITouchPhaseEnded];
|
||||
NSSet *cleared = [self copyClearedTouches:touches phase:UITouchPhaseEnded];
|
||||
[self.view touchesEnded:cleared withEvent:event];
|
||||
[cleared release];
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
@ -116,7 +121,7 @@ const CGFloat kGLGestureMovementDistance = 0.5;
|
|||
[self.view touchesCancelled:touches withEvent:event];
|
||||
};
|
||||
|
||||
- (NSSet *)clearTouches:(NSSet *)touches phase:(UITouchPhase)phaseToSave {
|
||||
- (NSSet *)copyClearedTouches:(NSSet *)touches phase:(UITouchPhase)phaseToSave {
|
||||
NSMutableSet *cleared = [touches mutableCopy];
|
||||
|
||||
for (UITouch *touch in touches) {
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
@interface ViewController : UIViewController <GKGameCenterControllerDelegate> {
|
||||
};
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:
|
||||
(UIInterfaceOrientation)p_orientation;
|
||||
|
||||
- (void)didReceiveMemoryWarning;
|
||||
|
||||
- (void)viewDidLoad;
|
||||
|
|
|
@ -42,12 +42,12 @@ int add_cmdline(int, char **);
|
|||
int add_path(int p_argc, char **p_args) {
|
||||
|
||||
NSString *str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"];
|
||||
if (!str)
|
||||
if (!str) {
|
||||
return p_argc;
|
||||
}
|
||||
|
||||
p_args[p_argc++] = "--path";
|
||||
[str retain]; // memory leak lol (maybe make it static here and delete it in ViewController destructor? @todo
|
||||
p_args[p_argc++] = (char *)[str cString];
|
||||
p_args[p_argc++] = (char *)"--path";
|
||||
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
p_args[p_argc] = NULL;
|
||||
|
||||
return p_argc;
|
||||
|
@ -60,12 +60,11 @@ int add_cmdline(int p_argc, char **p_args) {
|
|||
return p_argc;
|
||||
|
||||
for (int i = 0; i < [arr count]; i++) {
|
||||
|
||||
NSString *str = [arr objectAtIndex:i];
|
||||
if (!str)
|
||||
if (!str) {
|
||||
continue;
|
||||
[str retain]; // @todo delete these at some point
|
||||
p_args[p_argc++] = (char *)[str cString];
|
||||
}
|
||||
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
};
|
||||
|
||||
p_args[p_argc] = NULL;
|
||||
|
@ -81,7 +80,7 @@ int add_cmdline(int p_argc, char **p_args) {
|
|||
@implementation ViewController
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
|
||||
[super didReceiveMemoryWarning];
|
||||
printf("*********** did receive memory warning!\n");
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue