Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #62 from aclev/fixMemoryIssues
Browse files Browse the repository at this point in the history
fix memory issues in LiveConnectClientCore and LiveAuthStorage
  • Loading branch information
aclev committed May 11, 2015
2 parents c6e913c + 729478a commit a8168fb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion LiveSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "LiveSDK"
s.version = "5.6.1"
s.version = "5.6.2"
s.summary = "Client libraries for calling Live Services from iOS apps"
s.description = <<-DESC
Client libraries for calling the Live Services from iOS apps. Provides
Expand Down
2 changes: 1 addition & 1 deletion src/LiveSDK/Library/Internal/LiveAuthStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (id) initWithClientId:(NSString *)clientId
// Find the file path
NSString *libDirectory = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
_filePath = [[libDirectory stringByAppendingPathComponent:@"LiveService_auth.plist"] retain];
_clientId = clientId;
_clientId = [clientId retain];

// If file exist, load the file
if ([[NSFileManager defaultManager] fileExistsAtPath:_filePath])
Expand Down
20 changes: 13 additions & 7 deletions src/LiveSDK/Library/Internal/LiveConnectClientCore.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@
#import "LiveUploadOperationCore.h"
#import "StringHelper.h"


@implementation LiveConnectClientCore

@synthesize clientId = _clientId,
scopes = _scopes,
session = _session,
status = _status,
authRequest = _authRequest,
authRefreshRequest;
authRefreshRequest = _authRefreshRequest;


#pragma mark init and dealloc

Expand All @@ -55,6 +57,7 @@ - (id) initWithClientId:(NSString *)clientId
_storage = [[LiveAuthStorage alloc] initWithClientId:clientId];
_status = LiveAuthUnknown;
_session = nil;
_authRefreshRequest = nil;
}

[self refreshSessionWithDelegate:delegate
Expand All @@ -64,14 +67,18 @@ - (id) initWithClientId:(NSString *)clientId

- (void)dealloc
{
[authRefreshRequest cancel];
// Unfortunetly we must cancel the authRefreshRequest before we dealloc it
// so it does not call any of the delegate methods on a delegate that has been
// dealloced. when we set the authRefreshRequest to nil it will be autoreleased
[self.authRefreshRequest cancel];
self.authRefreshRequest = nil;


[_clientId release];
[_scopes release];
[_session release];
[_authRequest release];
[_storage release];
[authRefreshRequest release];

[super dealloc];
}
Expand Down Expand Up @@ -155,15 +162,14 @@ - (void) refreshSessionWithDelegate:(id<LiveAuthDelegate>)delegate
if ([LiveAuthHelper shouldRefreshToken:_session
refreshToken:_storage.refreshToken])
{
authRefreshRequest = [[[LiveAuthRefreshRequest alloc] initWithClientId:_clientId
self.authRefreshRequest = [[[LiveAuthRefreshRequest alloc] initWithClientId:_clientId
scope:_scopes
refreshToken:_storage.refreshToken
delegate:delegate
userState:userState
clientStub:self]
autorelease];
clientStub:self] autorelease];

[authRefreshRequest execute];
[self.authRefreshRequest execute];
}
else
{
Expand Down

0 comments on commit a8168fb

Please sign in to comment.