Skip to content

Commit

Permalink
Merge branch 'master' of github.com:appcelerator/titanium_mobile into…
Browse files Browse the repository at this point in the history
… TIMOB-24231
  • Loading branch information
Gary Mathews committed Dec 22, 2016
2 parents ec76446 + b5feb9a commit f74e40b
Show file tree
Hide file tree
Showing 43 changed files with 185 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto

public class TiBaseAdapter extends BaseAdapter {

Activity context;

public TiBaseAdapter(Activity activity) {
context = activity;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1498,21 +1498,7 @@ protected void onDestroy()
Log.d(TAG, "Activity " + this + " onDestroy", Log.DEBUG_MODE);
if (activityProxy != null) {
dispatchCallback(TiC.PROPERTY_ON_DESTROY, null);
activityProxy.release();
activityProxy = null;
}
if (view != null) {
view.releaseViews();
view.release();
view = null;
}
if (window != null) {
window.releaseViews();
window.removeAllChildren();
window.release();
window = null;
}
layout = null;

inForeground = false;
TiApplication tiApp = getTiApp();
Expand Down Expand Up @@ -1566,11 +1552,15 @@ protected void onDestroy()
//LW windows
if (window == null && view != null) {
view.releaseViews();
view.release();
view = null;
}

if (window != null) {
window.closeFromActivity(isFinishing);
window.releaseViews();
window.removeAllChildren();
window.release();
window = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ public int write(int position, byte[] sourceBuffer, int sourceOffset, int source
@Kroll.method
public int append(Object[] args)
{
if (args.length < 1) {
throw new IllegalArgumentException("At least 1 argument required for append: src");
}
int destLength = buffer.length;
BufferProxy src = (BufferProxy) args[0];
byte[] sourceBuffer = src.getBuffer();
Expand Down
11 changes: 10 additions & 1 deletion apidoc/Titanium/UI/Button.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,16 @@ properties:
state only. For iOS, since there is not a trackball, this does nothing.
type: String
platforms: [android, iphone, ipad, mobileweb]


- name: backgroundSelectedColor
summary: Selected background color of the view, as a color name or hex triplet.
description: |
For information about color values, see the "Colors" section of <Titanium.UI>.
type: String
platforms: [iphone, ipad, android, mobileweb]
default: Background color of this view.
since: {iphone: "6.1.0", ipad: "6.1.0", android: 0.9.0, mobileweb: 1.8.0}

- name: backgroundSelectedImage
summary: |
Background image for the button in its selected state, specified as a local file
Expand Down
2 changes: 1 addition & 1 deletion build/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function downloadURL(url, callback) {
if (req.statusCode >= 400) {
// something went wrong, abort
console.log();
console.error('Request failed with HTTP status code %s %s', req.statusCode, http.STATUS_CODES[req.statusCode] || '');
console.error('Request failed with HTTP status code %s %s', req.statusCode, req.statusMessage);
return callback(err);
} else if (req.headers['content-length']) {
// we know how big the file is, display the progress bar
Expand Down
5 changes: 3 additions & 2 deletions iphone/Classes/CalendarModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ -(void) eventStoreChanged:(NSNotification*)notification

-(void)dealloc
{
RELEASE_TO_NIL(store);
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
[store release];
[[NSNotificationCenter defaultCenter] removeObserver:self];

}

-(void)didReceiveMemoryWarning:(NSNotification*)notification
Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/FilesystemModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ -(id)getAsset:(id)args
RELEASE_TO_NIL(sha)
}
}
return [[TiBlob alloc] _initWithPageContext:[self executionContext] andImage:image];
return [[[TiBlob alloc] _initWithPageContext:[self executionContext] andImage:image] autorelease];
}
return [NSNull null];
}
Expand All @@ -252,4 +252,4 @@ -(NSString*)IOS_FILE_PROTECTION_COMPLETE_UNTIL_FIRST_USER_AUTHENTICATION

@end

#endif
#endif
4 changes: 2 additions & 2 deletions iphone/Classes/GeolocationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ -(void)reverseGeocoder:(id)args
ENSURE_ARG_COUNT(args,3);
KrollCallback *callback = [args objectAtIndex:2];
ENSURE_TYPE(callback,KrollCallback);
#ifndef __clang_analyzer__ //ignore static analyzer error here, memory will be released
#ifndef __clang_analyzer__ // Ignore static analyzer error here, memory will be released. See TIMOB-19444
CGFloat lat = [TiUtils floatValue:[args objectAtIndex:0]];
CGFloat lon = [TiUtils floatValue:[args objectAtIndex:1]];
ReverseGeoCallback *rcb = [[ReverseGeoCallback alloc] initWithCallback:callback context:[self executionContext]];
Expand All @@ -548,7 +548,7 @@ -(void)forwardGeocoder:(id)args
ENSURE_ARG_COUNT(args,2);
KrollCallback *callback = [args objectAtIndex:1];
ENSURE_TYPE(callback,KrollCallback);
#ifndef __clang_analyzer__ //ignore static analyzer error here, memory will be released
#ifndef __clang_analyzer__ // Ignore static analyzer error here, memory will be released. See TIMOB-19444
ForwardGeoCallback *fcb = [[ForwardGeoCallback alloc] initWithCallback:callback context:[self executionContext]];
[self performGeo:@"f" address:[TiUtils stringValue:[args objectAtIndex:0]] callback:fcb];
#endif
Expand Down
14 changes: 7 additions & 7 deletions iphone/Classes/KrollBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ - (TiModule *)loadTopLevelNativeModule:(TiModule *)module withPath:(NSString *)p
return module;
}

NSString* contents = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString* contents = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
KrollWrapper* wrapper = (id) [self loadJavascriptText:contents fromFile:path withContext:kroll];

// For right now, we need to mix any compiled JS on top of a compiled module, so that both components
Expand Down Expand Up @@ -904,7 +904,7 @@ - (TiModule *)loadCoreModule:(NSString *)path withContext:(KrollContext *)kroll
// nope, return nil so we can try to fall back to resource in user's app
return nil;
}
NSString* contents = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString* contents = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
// This is an asset inside the native module. Load it like a "normal" common js file
return [self loadJavascriptText:contents fromFile:filepath withContext:kroll];
}
Expand All @@ -920,7 +920,7 @@ - (NSString *)loadFile:(NSString *)path

if (data != nil) {
[self setCurrentURL:[NSURL URLWithString:[path stringByDeletingLastPathComponent] relativeToURL:[[self host] baseURL]]];
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
return [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
}
return nil;
}
Expand Down Expand Up @@ -1099,19 +1099,19 @@ - (NSArray *)nodeModulesPaths:(NSString *)path
path = @"/";
}
// 1. let PARTS = path split(START)
NSArray* parts = [path componentsSeparatedByString:@"/"];
NSArray *parts = [path componentsSeparatedByString:@"/"];
// 2. let I = count of PARTS - 1
NSInteger i = [parts count] - 1;
// 3. let DIRS = []
NSMutableArray* dirs = [[NSMutableArray alloc] initWithCapacity:0];
NSMutableArray *dirs = [NSMutableArray arrayWithCapacity:0];
// 4. while I >= 0,
while (i >= 0) {
// a. if PARTS[I] = "node_modules" CONTINUE
if ([[parts objectAtIndex:i] isEqual: @"node_modules"]) {
continue;
}
// b. DIR = path join(PARTS[0 .. I] + "node_modules")
NSString* dir = [[[parts componentsJoinedByString:@"/"] substringFromIndex:1] stringByAppendingPathComponent:@"node_modules"];
NSString *dir = [[[parts componentsJoinedByString:@"/"] substringFromIndex:1] stringByAppendingPathComponent:@"node_modules"];
// c. DIRS = DIRS + DIR
[dirs addObject:dir];
// d. let I = I - 1
Expand Down Expand Up @@ -1302,8 +1302,8 @@ + (KrollBridge *)krollBridgeForThreadName:(NSString *)threadName;
CFSetGetValues(krollBridgeRegistry, (const void **)registryObjects);
for (int currentBridgeIndex = 0; currentBridgeIndex < bridgeCount; currentBridgeIndex++)
{
KrollBridge * currentBridge = registryObjects[currentBridgeIndex];
#ifdef TI_USE_KROLL_THREAD
KrollBridge * currentBridge = registryObjects[currentBridgeIndex];
if ([[[currentBridge krollContext] threadName] isEqualToString:threadName])
{
result = [[currentBridge retain] autorelease];
Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/MediaModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -1052,9 +1052,9 @@ -(void)requestPhotoGalleryPermissions:(id)arg
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
BOOL granted = (status == PHAuthorizationStatusAuthorized);
NSString *errorMessage = granted ? @"" : @"The user denied access to use the photo gallery.";
KrollEvent *invocationEvent = [[KrollEvent alloc] initWithCallback:callback
KrollEvent *invocationEvent = [[[KrollEvent alloc] initWithCallback:callback
eventObject:[TiUtils dictionaryWithCode:(granted ? 0 : 1) message:errorMessage]
thisObject:self];
thisObject:self] autorelease];
[[callback context] enqueue:invocationEvent];
}];
}, YES);
Expand Down
3 changes: 1 addition & 2 deletions iphone/Classes/TiAnimation.m
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ -(void)dealloc
RELEASE_TO_NIL(transition);
RELEASE_TO_NIL(callback);
RELEASE_TO_NIL(view);
RELEASE_TO_NIL(animatedView);
[animatedViewProxy release];
[animatedViewProxy release];
[super dealloc];
}

Expand Down
3 changes: 1 addition & 2 deletions iphone/Classes/TiApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -1179,8 +1179,7 @@ - (NSString*)systemUserAgent
NSString *currentLocaleIdentifier = [[NSLocale currentLocale] localeIdentifier];
NSString *currentDeviceInfo = [NSString stringWithFormat:@"%@/%@; %@; %@;",[currentDevice model],[currentDevice systemVersion],[currentDevice systemName],currentLocaleIdentifier];
NSString *kTitaniumUserAgentPrefix = [NSString stringWithFormat:@"%s%s%s %s%s","Appc","eler","ator","Tita","nium"];

return [[NSString stringWithFormat:@"%@/%s (%@)",kTitaniumUserAgentPrefix,TI_VERSION_STR,currentDeviceInfo] retain];
return [NSString stringWithFormat:@"%@/%s (%@)",kTitaniumUserAgentPrefix,TI_VERSION_STR,currentDeviceInfo];
}

- (NSString*)userAgent
Expand Down
6 changes: 4 additions & 2 deletions iphone/Classes/TiAppiOSProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ -(void)didReceiveApplicationShortcutNotification:(NSNotification*)info
}

[self fireEvent:@"shortcutitemclick" withObject:event];
RELEASE_TO_NIL(event);
}

-(void)didHandleURL:(NSNotification*)info
Expand Down Expand Up @@ -623,13 +624,14 @@ -(id)scheduleLocalNotification:(id)args
CLLocationCoordinate2D center = CLLocationCoordinate2DMake(latitude, longitude);

if (!CLLocationCoordinate2DIsValid(center)) {
RELEASE_TO_NIL(localNotif);
NSLog(@"[WARN] The provided region is invalid, please check your `latitude` and `longitude`!");
return;
}

localNotif.region = [[CLCircularRegion alloc] initWithCenter:center
localNotif.region = [[[CLCircularRegion alloc] initWithCenter:center
radius:kCLDistanceFilterNone
identifier:identifier ? identifier : @"notification"];
identifier:identifier ? identifier : @"notification"] autorelease];

localNotif.regionTriggersOnce = regionTriggersOnce;
}
Expand Down
7 changes: 3 additions & 4 deletions iphone/Classes/TiAppiOSSearchQueryProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ - (void)dealloc

- (id)_initWithPageContext:(id<TiEvaluator>)context andArguments:(NSDictionary*)args
{
if (self == [super _initWithPageContext:context]) {
ENSURE_TYPE([args objectForKey:@"queryString"], NSString);
ENSURE_TYPE([args objectForKey:@"attributes"], NSArray);

ENSURE_TYPE([args objectForKey:@"queryString"], NSString);
ENSURE_TYPE([args objectForKey:@"attributes"], NSArray);
if (self = [super _initWithPageContext:context]) {
queryString = [[args objectForKey:@"queryString"] retain];
attributes = [[args objectForKey:@"attributes"] retain];
}
Expand Down
6 changes: 6 additions & 0 deletions iphone/Classes/TiAppiOSSearchableItemProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ -(id)initWithUniqueIdentifier:(NSString *)identifier
return self;
}

-(void)dealloc
{
RELEASE_TO_NIL(_item);
[super dealloc];
}

-(NSString*)apiName
{
return @"Ti.App.iOS.SearchableItem";
Expand Down
3 changes: 2 additions & 1 deletion iphone/Classes/TiAppiOSUserActivityProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ -(id)initWithOptions:(NSDictionary*)props

-(void)dealloc
{
if(_supported){
if (_supported) {
[self clean];
}
RELEASE_TO_NIL(_userActivity);
[super dealloc];
}

Expand Down
17 changes: 15 additions & 2 deletions iphone/Classes/TiContactsGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,11 @@ -(void)add:(id)arg
subreason:nil
location:CODELOCATION];
};
// Ignore static analylzer warning here
// This is to release the saverequest in TiContactsPerson.m line 965 in (CNSaveRequest*)getSaveRequestForAddition
#ifndef __clang_analyzer__
RELEASE_TO_NIL(saveRequest)
#endif
return;
}

Expand Down Expand Up @@ -321,7 +325,11 @@ -(void)remove:(id)arg
subreason:nil
location:CODELOCATION];
};
// Ignore static analyzer warning here
// This is to release the saverequest in TiContactsPerson.m line 956 in (CNSaveRequest*)getSaveRequestForDeletion
#ifndef __clang_analyzer__
RELEASE_TO_NIL(saveRequest)
#endif
return;
}

Expand All @@ -338,19 +346,24 @@ -(void)remove:(id)arg
}

//For iOS9 deleting contact
#ifndef __clang_analyzer__
-(CNSaveRequest*)getSaveRequestForDeletion
{
CNSaveRequest *saveRequest = [[CNSaveRequest alloc] init];
[saveRequest deleteGroup: [[group mutableCopy] autorelease]];
// Do not be tempted to autorelease here. https://github.com/appcelerator/titanium_mobile/commit/a0d4a50d51f1afe85f92cf9e0d2ce8cca08fcf2f
// It will be released in ContactsModule.m line 315 in (void)save
return saveRequest;
}

-(CNSaveRequest*)getSaveRequestForAddition: (NSString*)containerIdentifier
{
CNSaveRequest *saveRequest = [[CNSaveRequest alloc] init];
[saveRequest addGroup:group toContainerWithIdentifier:containerIdentifier];
// Do not be tempted to autorelease here. https://github.com/appcelerator/titanium_mobile/commit/a0d4a50d51f1afe85f92cf9e0d2ce8cca08fcf2f
// It will be released in ContactsModule.m line 315 in (void)save
return saveRequest;
}

#endif
@end
#endif
#endif

0 comments on commit f74e40b

Please sign in to comment.