comparison src/video/uikit/SDL_uikitview.m @ 5051:a69e36365766

Fixed bug #1027 Vittorio Giovara 2010-07-17 19:21:36 PDT fix the double free error in SDL_uikitview the variable 'textfield' is initialialized and set to autorelease. however in the dealloc method a second [release] is sent. If the textfield has not been set to nil before (with a viewDidUnload for example) this can lead to awful hard-to-find crashes when the SDL code terminates. the error message is -[textfield release] message sent to deallocated instance 0x4e5fa90 the fix is simple, just release the object as soon as it is added to the subview, see attached patch
author Sam Lantinga <slouken@libsdl.org>
date Wed, 19 Jan 2011 23:45:29 -0800
parents c24ba2cc9583
children 25d4feb7c127
comparison
equal deleted inserted replaced
5050:2add0d17180b 5051:a69e36365766
33 #endif 33 #endif
34 34
35 @implementation SDL_uikitview 35 @implementation SDL_uikitview
36 36
37 - (void)dealloc { 37 - (void)dealloc {
38 #if SDL_IPHONE_KEYBOARD
39 [textField release];
40 #endif
41 [super dealloc]; 38 [super dealloc];
42 } 39 }
43 40
44 - (id)initWithFrame:(CGRect)frame { 41 - (id)initWithFrame:(CGRect)frame {
45 42
218 } 215 }
219 216
220 /* Set ourselves up as a UITextFieldDelegate */ 217 /* Set ourselves up as a UITextFieldDelegate */
221 - (void)initializeKeyboard { 218 - (void)initializeKeyboard {
222 219
223 textField = [[[UITextField alloc] initWithFrame: CGRectZero] autorelease]; 220 textField = [[UITextField alloc] initWithFrame: CGRectZero];
224 textField.delegate = self; 221 textField.delegate = self;
225 /* placeholder so there is something to delete! */ 222 /* placeholder so there is something to delete! */
226 textField.text = @" "; 223 textField.text = @" ";
227 224
228 /* set UITextInputTrait properties, mostly to defaults */ 225 /* set UITextInputTrait properties, mostly to defaults */
236 233
237 textField.hidden = YES; 234 textField.hidden = YES;
238 keyboardVisible = NO; 235 keyboardVisible = NO;
239 /* add the UITextField (hidden) to our view */ 236 /* add the UITextField (hidden) to our view */
240 [self addSubview: textField]; 237 [self addSubview: textField];
238 [textField release];
241 } 239 }
242 240
243 /* reveal onscreen virtual keyboard */ 241 /* reveal onscreen virtual keyboard */
244 - (void)showKeyboard { 242 - (void)showKeyboard {
245 keyboardVisible = YES; 243 keyboardVisible = YES;