[Scummvm-git-logs] scummvm master -> 69e3b098dcd5a5fb0df553b65b5a7978767987c6

larsamannen noreply at scummvm.org
Thu Aug 8 05:41:26 UTC 2024


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a3f1678f3f IOS7: Do not return in textFields when Return key is pressed
6eac13847e IOS7: Autorelease overloaded key arrays
69e3b098dc IOS7: Fix memleaks in Gamepad controller


Commit: a3f1678f3f3676be687bc6514ff56945399c2548
    https://github.com/scummvm/scummvm/commit/a3f1678f3f3676be687bc6514ff56945399c2548
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2024-08-08T07:41:22+02:00

Commit Message:
IOS7: Do not return in textFields when Return key is pressed

The default behavior when pressing the Return key in an iOS
application is that the keyboard is dismissed. This cause
problems in games like Grim Fandango which is played using a
keyboard instead of a mouse. If the user press the Return key
the keyboard is dismissed which makes it impossible for the
user to press other keys.

Do not dismiss the keyboard when Return key is pressed.

Changed paths:
    backends/platform/ios7/ios7_keyboard.mm


diff --git a/backends/platform/ios7/ios7_keyboard.mm b/backends/platform/ios7/ios7_keyboard.mm
index 1f8d3df746d..c07d38a855d 100644
--- a/backends/platform/ios7/ios7_keyboard.mm
+++ b/backends/platform/ios7/ios7_keyboard.mm
@@ -763,6 +763,11 @@
 	return YES;
 }
 
+- (BOOL)textFieldShouldReturn:(UITextField *)textField {
+	[inputView returnKey];
+	return NO;
+}
+
 - (void)textFieldDidBeginEditing:(UITextField *)textField {
 	if (ConfMan.getBool("keyboard_fn_bar"))
 		[inputView attachAccessoryView];


Commit: 6eac13847ec9ed7ca1f37d3e9c5b2947f28b627f
    https://github.com/scummvm/scummvm/commit/6eac13847ec9ed7ca1f37d3e9c5b2947f28b627f
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2024-08-08T07:41:22+02:00

Commit Message:
IOS7: Autorelease overloaded key arrays

There are memory leakages when returning to the ScummVM iOS
application if it has been running in background.
The reason for the memory leaks is that the system calls the
keyCommands function every time the keyboard view became the
first responder.

Since the overloaded keys are loaded into allocated arrays
each time the keyCommands function is called they are never
released. Since the keyCommands is running in an autorelease
block, make the allocation to autorelease.

This is required since we don't utilize ARC.

Changed paths:
    backends/platform/ios7/ios7_keyboard.mm


diff --git a/backends/platform/ios7/ios7_keyboard.mm b/backends/platform/ios7/ios7_keyboard.mm
index c07d38a855d..5e740f99ff8 100644
--- a/backends/platform/ios7/ios7_keyboard.mm
+++ b/backends/platform/ios7/ios7_keyboard.mm
@@ -281,7 +281,7 @@
 }
 
 - (NSArray *)overloadKeys:(NSArray<NSString *> *)keys withSelector:(SEL)selector {
-	NSMutableArray<UIKeyCommand *> *overloadedKeys = [[NSMutableArray alloc] init];
+	NSMutableArray<UIKeyCommand *> *overloadedKeys = [[[NSMutableArray alloc] init] autorelease];
 	for (NSString *key in keys) {
 		[overloadedKeys addObject:[self createKeyCommandForKey:key withModifierFlags:0 andSelector:selector]];
 		[overloadedKeys addObject:[self createKeyCommandForKey:key withModifierFlags:UIKeyModifierShift andSelector:selector]];
@@ -296,13 +296,13 @@
 }
 
 - (NSArray *)overloadArrowKeys {
-	NSArray<NSString *> *arrowKeys = [[NSArray alloc] initWithObjects:UIKeyInputUpArrow, UIKeyInputDownArrow, UIKeyInputLeftArrow, UIKeyInputRightArrow, nil];
+	NSArray<NSString *> *arrowKeys = [[[NSArray alloc] initWithObjects:UIKeyInputUpArrow, UIKeyInputDownArrow, UIKeyInputLeftArrow, UIKeyInputRightArrow, nil] autorelease];
 	return [self overloadKeys:arrowKeys withSelector:@selector(handleArrowKey:)];
 }
 
 - (NSArray *)overloadRomanLetters {
 	NSString *romanLetters = @"abcdefghijklmnopqrstuvwxyz";
-	NSMutableArray<NSString *> *letters = [[NSMutableArray alloc] init];
+	NSMutableArray<NSString *> *letters = [[[NSMutableArray alloc] init] autorelease];
 	for (NSUInteger x = 0; x < romanLetters.length; x++) {
 		unichar c = [romanLetters characterAtIndex:x];
 		[letters addObject:[NSString stringWithCharacters:&c length:1]];
@@ -312,7 +312,7 @@
 
 - (NSArray *)overloadNumbers {
 	NSString *numbers = @"0123456789";
-	NSMutableArray<NSString *> *numArray = [[NSMutableArray alloc] init];
+	NSMutableArray<NSString *> *numArray = [[[NSMutableArray alloc] init] autorelease];
 	for (NSUInteger x = 0; x < numbers.length; x++) {
 		unichar c = [numbers characterAtIndex:x];
 		[numArray addObject:[NSString stringWithCharacters:&c length:1]];
@@ -323,7 +323,7 @@
 - (NSArray *)overloadFnKeys {
 #ifdef __IPHONE_13_4
 	if (@available(iOS 13.4, *)) {
-		NSArray<NSString *> *fnKeys = [[NSArray alloc] initWithObjects:UIKeyInputF1, UIKeyInputF2, UIKeyInputF3, UIKeyInputF4, UIKeyInputF5, UIKeyInputF6, UIKeyInputF7, UIKeyInputF8, UIKeyInputF9, UIKeyInputF10, UIKeyInputF11, UIKeyInputF12, nil];
+		NSArray<NSString *> *fnKeys = [[[NSArray alloc] initWithObjects:UIKeyInputF1, UIKeyInputF2, UIKeyInputF3, UIKeyInputF4, UIKeyInputF5, UIKeyInputF6, UIKeyInputF7, UIKeyInputF8, UIKeyInputF9, UIKeyInputF10, UIKeyInputF11, UIKeyInputF12, nil] autorelease];
 		return [self overloadKeys:fnKeys withSelector:@selector(handleFnKey:)];
 	}
 #endif
@@ -332,7 +332,7 @@
 
 - (NSArray *)overloadSpecialKeys {
 #ifdef __IPHONE_13_4
-	NSMutableArray<NSString *> *specialKeys = [[NSMutableArray alloc] initWithObjects:UIKeyInputEscape, UIKeyInputPageUp, UIKeyInputPageDown, nil];
+	NSMutableArray<NSString *> *specialKeys = [[[NSMutableArray alloc] initWithObjects:UIKeyInputEscape, UIKeyInputPageUp, UIKeyInputPageDown, nil] autorelease];
 
 	if (@available(iOS 13.4, *)) {
 		[specialKeys addObject: UIKeyInputHome];
@@ -479,7 +479,7 @@
 }
 
 - (NSArray *)keyCommands {
-	NSMutableArray<UIKeyCommand *> *overloadedKeys = [[NSMutableArray alloc] init];
+	NSMutableArray<UIKeyCommand *> *overloadedKeys = [[[NSMutableArray alloc] init] autorelease];
 	// Arrows
 	[overloadedKeys addObjectsFromArray:[self overloadArrowKeys]];
 	// Roman letters


Commit: 69e3b098dcd5a5fb0df553b65b5a7978767987c6
    https://github.com/scummvm/scummvm/commit/69e3b098dcd5a5fb0df553b65b5a7978767987c6
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2024-08-08T07:41:22+02:00

Commit Message:
IOS7: Fix memleaks in Gamepad controller

Make sure to decrement the reference counter on allocated objects.

Changed paths:
    backends/platform/ios7/ios7_gamepad_controller.mm


diff --git a/backends/platform/ios7/ios7_gamepad_controller.mm b/backends/platform/ios7/ios7_gamepad_controller.mm
index 468c26e4cc5..48af55ab30b 100644
--- a/backends/platform/ios7/ios7_gamepad_controller.mm
+++ b/backends/platform/ios7/ios7_gamepad_controller.mm
@@ -84,14 +84,14 @@
 		[_fullSetElementsThumbstick addObjectsFromArray:_commonElements];
 		[_fullSetElementsThumbstick addObjectsFromArray:_additionalElements];
 	
-		NSMutableSet<NSString *> *_miniSetElementsThumbstick = [[NSMutableSet alloc] initWithObjects:GCInputLeftThumbstick,  nil];
+		NSMutableSet<NSString *> *_miniSetElementsThumbstick = [[NSMutableSet alloc] initWithObjects:GCInputLeftThumbstick, nil];
 		[_miniSetElementsThumbstick addObjectsFromArray:_commonElements];
 
 		NSMutableSet<NSString *> *_fullSetElementsDpad = [[NSMutableSet alloc] initWithObjects: GCInputDirectionalDpad, nil];
 		[_fullSetElementsDpad addObjectsFromArray:_commonElements];
 		[_fullSetElementsDpad addObjectsFromArray:_additionalElements];
 
-		NSMutableSet<NSString *> *_miniSetElementsDpad = [[NSMutableSet alloc] initWithObjects:GCInputDirectionalDpad,  nil];
+		NSMutableSet<NSString *> *_miniSetElementsDpad = [[NSMutableSet alloc] initWithObjects:GCInputDirectionalDpad, nil];
 		[_miniSetElementsDpad addObjectsFromArray:_commonElements];
 
 		_configThumbstick.elements = _fullSetElementsThumbstick;
@@ -99,11 +99,23 @@
 		_configDpad.elements = _fullSetElementsDpad;
 		_configMiniDpad.elements = _miniSetElementsDpad;
 
+		[_miniSetElementsDpad release];
+		[_fullSetElementsDpad release];
+		[_miniSetElementsThumbstick release];
+		[_fullSetElementsThumbstick release];
+		[_commonElements release];
+		[_additionalElements release];
+
 		_virtualControllerThumbstick = [[GCVirtualController alloc] initWithConfiguration:_configThumbstick];
 		_virtualControllerMiniThumbstick = [[GCVirtualController alloc] initWithConfiguration:_configMiniThumbstick];
 		_virtualControllerDpad = [[GCVirtualController alloc] initWithConfiguration:_configDpad];
 		_virtualControllerMiniDpad = [[GCVirtualController alloc] initWithConfiguration:_configMiniDpad];
 		_currentController = _virtualControllerThumbstick;
+
+		[_configDpad release];
+		[_configMiniDpad release];
+		[_configThumbstick release];
+		[_configMiniThumbstick release];
 	}
 #endif
 #endif




More information about the Scummvm-git-logs mailing list