Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-24549
Browse files Browse the repository at this point in the history
  • Loading branch information
garymathews committed Dec 8, 2020
2 parents f8ad156 + e6a8710 commit f3ef6f8
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 73 deletions.
Binary file modified android/titanium/lib/aps-analytics.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ public void onDisposing(KrollRuntime runtime)

// Delete all Titanium temp files.
deleteTiTempFiles();

if (isAnalyticsEnabled()) {

// Force send `session.end` event.
APSAnalytics.getInstance().sendSessionEndEvent(true);
}
}
});
}
Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/GeolocationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ - (void)performGeo:(NSString *)direction address:(NSString *)address callback:(G
[params setValue:countryCode forKey:@"c"];
}
[callback start:params];
RELEASE_TO_NIL(params);
}

- (JSValue *)reverseGeocoder:(double)latitude longitude:(double)longitude withCallback:(JSValue *)callback
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/MediaModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,8 @@ - (void)showPHPicker:(NSDictionary *)args

[_phPicker setDelegate:self];
[self displayModalPicker:_phPicker settings:args];

RELEASE_TO_NIL(configuration);
}

#pragma mark PHPickerViewControllerDelegate
Expand Down
5 changes: 5 additions & 0 deletions iphone/Classes/TiAppiOSProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ - (void)registerUserNotificationSettings:(id)args
// Assign the granted categories
[event setValue:((categories != nil) ? categories : @{}) forKey:@"categories"];
[self fireEvent:@"usernotificationsettings" withObject:event];
RELEASE_TO_NIL(event);
}];
}
}
Expand Down Expand Up @@ -846,6 +847,10 @@ - (void)assignUserInfo:(NSDictionary *)userInfo toContent:(id)content ensureIden
} else if ([content isKindOfClass:UILocalNotification.class]) {
((UILocalNotification *)content).userInfo = userInfoWithId;
}

if (userInfo != nil) {
RELEASE_TO_NIL(userInfoWithId);
}
}

- (void)cancelAllLocalNotifications:(id)unused
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiAppiOSUserNotificationCenterProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ - (void)removePendingNotifications:(id)args
if (identifiers.count > 0) {
[center removePendingNotificationRequestsWithIdentifiers:identifiers];
}
RELEASE_TO_NIL(identifiers);
}];
}

Expand Down Expand Up @@ -113,6 +114,7 @@ - (void)removeDeliveredNotifications:(id)args
if (identifiers.count > 0) {
[center removeDeliveredNotificationsWithIdentifiers:identifiers];
}
RELEASE_TO_NIL(identifiers);
}];
}

Expand Down
16 changes: 8 additions & 8 deletions iphone/Classes/TiDOMNodeProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
#import "TiDOMValidator.h"
#import <TitaniumKit/TiUtils.h>
#include <libkern/OSAtomic.h>

#import <os/lock.h>
/*
* The nodeRegistry is used to map xmlNodePtr objects to TiDOMNodeProxies
* Ensures that there is only one active proxy for a give xmlNodePtr.
* Values are inserted when the proxies are created
* Values are removed when the proxies are freed
*/
static CFMutableDictionaryRef nodeRegistry = NULL;
OSSpinLock nodeRegistryLock = OS_SPINLOCK_INIT;
os_unfair_lock nodeRegistryLock = OS_UNFAIR_LOCK_INIT;

@implementation TiDOMNodeProxy
@synthesize document, node;
Expand Down Expand Up @@ -62,11 +62,11 @@ - (NSString *)XMLString
+ (id)nodeForXMLNode:(xmlNodePtr)nodePtr
{
id result = nil;
OSSpinLockLock(&nodeRegistryLock);
os_unfair_lock_lock(&nodeRegistryLock);
if (nodeRegistry != NULL) {
result = CFDictionaryGetValue(nodeRegistry, nodePtr);
}
OSSpinLockUnlock(&nodeRegistryLock);
os_unfair_lock_unlock(&nodeRegistryLock);
return result;
}

Expand All @@ -85,7 +85,7 @@ + (void)setNode:(id)node forXMLNode:(xmlNodePtr)nodePtr
if ((node == nil) || (nodePtr == NULL)) {
return;
}
OSSpinLockLock(&nodeRegistryLock);
os_unfair_lock_lock(&nodeRegistryLock);
if (nodeRegistry == NULL) {
CFDictionaryKeyCallBacks keyCallbacks = kCFTypeDictionaryKeyCallBacks;
CFDictionaryValueCallBacks callbacks = kCFTypeDictionaryValueCallBacks;
Expand All @@ -98,16 +98,16 @@ + (void)setNode:(id)node forXMLNode:(xmlNodePtr)nodePtr
nodeRegistry = CFDictionaryCreateMutable(nil, 0, &keyCallbacks, &callbacks);
}
CFDictionarySetValue(nodeRegistry, (void *)nodePtr, node);
OSSpinLockUnlock(&nodeRegistryLock);
os_unfair_lock_unlock(&nodeRegistryLock);
}

+ (void)removeNodeForXMLNode:(xmlNodePtr)nodePtr
{
OSSpinLockLock(&nodeRegistryLock);
os_unfair_lock_lock(&nodeRegistryLock);
if (nodeRegistry == NULL)
return;
CFDictionaryRemoveValue(nodeRegistry, nodePtr);
OSSpinLockUnlock(&nodeRegistryLock);
os_unfair_lock_unlock(&nodeRegistryLock);
}

- (id)makeNodeListProxyFromArray:(NSArray *)nodes context:(id<TiEvaluator>)context
Expand Down
3 changes: 3 additions & 0 deletions iphone/Classes/TiUIListView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,9 @@ - (void)tableViewDidEndMultipleSelectionInteraction:(UITableView *)tableView
[startingItem setDictionary:eventObject];
}
[selectedItems addObject:eventObject];

RELEASE_TO_NIL(eventObject);
RELEASE_TO_NIL(theSection);
}
[self.proxy fireEvent:@"itemsselected" withObject:@{ @"selectedItems" : selectedItems, @"startingItem" : startingItem }];
}
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiUIShortcutProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
READONLY_PROPERTY(NSArray<TiUIShortcutItemProxy *> *, items, Items);
READONLY_PROPERTY(NSArray<TiUIShortcutItemProxy *> *, staticItems, StaticItems);

- (TiUIShortcutItemProxy *)getById:(NSString *)identifier;
- (TiUIShortcutItemProxy *_Nullable)getById:(NSString *)identifier;

- (void)remove:(TiUIShortcutItemProxy *)shortcut;

Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/TiUIShortcutProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ - (void)remove:(TiUIShortcutItemProxy *)shortcut
}
}
UIApplication.sharedApplication.shortcutItems = shortcutsCopy;
RELEASE_TO_NIL(shortcutsCopy);
}
}

Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiUITabGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ - (NSDictionary *)focusEvent
index = [tabArray indexOfObject:[(TiUITabProxy *)focusedTabProxy controller]];
}
return @{
@"tab" : focusedTabProxy,
@"tab" : NULL_IF_NIL(focusedTabProxy),
@"index" : NUMINTEGER(index),
@"previousIndex" : NUMINT(-1),
@"previousTab" : [NSNull null]
Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/TiUITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -2403,6 +2403,7 @@ - (void)viewGetFocus
if (!controller.navigationItem.searchController) {
controller.navigationItem.searchController = searchController;
}
RELEASE_TO_NIL(controller);
}
if (!hideOnSearch && isSearched && self.searchedString && ![searchController isActive]) {
isSearched = NO;
Expand Down
8 changes: 5 additions & 3 deletions iphone/Classes/TiUIiOSPreviewContextProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ - (void)dealloc

- (void)connectToDelegate
{
#ifndef __clang_analyzer__
UIView *nativeSourceView = nil;

#ifdef USE_TI_UILISTVIEW
Expand All @@ -79,9 +78,12 @@ - (void)connectToDelegate
nativeSourceView = [_sourceView view];
}
UIViewController *controller = [[[TiApp app] controller] topPresentedController];
[controller registerForPreviewingWithDelegate:[[TiPreviewingDelegate alloc] initWithPreviewContext:self]
TiPreviewingDelegate *previewingDelegate = [[TiPreviewingDelegate alloc] initWithPreviewContext:self];

[controller registerForPreviewingWithDelegate:previewingDelegate
sourceView:nativeSourceView];
#endif

RELEASE_TO_NIL(previewingDelegate);
}

@end
Expand Down
6 changes: 3 additions & 3 deletions iphone/Classes/TiUIiOSProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ - (TiBlob *)systemImage:(id)arg
return nil;
}
ENSURE_SINGLE_ARG_OR_NIL(arg, NSString);
TiBlob *blob = [[TiBlob alloc] initWithSystemImage:arg];
TiBlob *blob = [[[TiBlob alloc] initWithSystemImage:arg] autorelease];
return blob;
}
#endif
Expand Down Expand Up @@ -912,9 +912,9 @@ - (TiColor *)fetchSemanticColor:(id)color
DEPRECATED_REPLACED(@"UI.iOS.fetchSemanticColor", @"9.1.0", @"UI.fetchSemanticColor");

if ([TiUtils isIOSVersionOrGreater:@"11.0"]) {
return [[TiColor alloc] initWithColor:[UIColor colorNamed:color] name:nil];
return [[[TiColor alloc] initWithColor:[UIColor colorNamed:color] name:nil] autorelease];
}
return [[TiColor alloc] initWithColor:UIColor.blackColor name:@"black"];
return [[[TiColor alloc] initWithColor:UIColor.blackColor name:@"black"] autorelease];
}

@end
Expand Down
3 changes: 2 additions & 1 deletion iphone/TitaniumKit/TitaniumKit/Sources/API/KrollBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "TiEvaluator.h"
#import "TiModule.h"
#import "TiProxy.h"
#import <os/lock.h>

@import Foundation;
@import JavaScriptCore;
Expand All @@ -34,7 +35,7 @@ extern NSString *TitaniumModuleRequireFormat;
//CFMutableDictionaryRefs only retain keys, which lets them work with proxies properly.
CFMutableDictionaryRef registeredProxies;
NSCondition *shutdownCondition;
OSSpinLock proxyLock;
os_unfair_lock proxyLock;
}
- (void)boot:(id)callback url:(NSURL *)url_ preload:(NSDictionary *)preload_;
- (void)evalJSWithoutResult:(NSString *)code;
Expand Down

0 comments on commit f3ef6f8

Please sign in to comment.