Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 57A519DAE for ; Fri, 18 May 2012 22:15:33 +0000 (UTC) Received: (qmail 74409 invoked by uid 500); 18 May 2012 22:15:33 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 74309 invoked by uid 500); 18 May 2012 22:15:33 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 74294 invoked by uid 99); 18 May 2012 22:15:33 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 May 2012 22:15:33 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C960916CA9; Fri, 18 May 2012 22:15:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: filmaj@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [2/3] ios commit: Fixed EXC_BAD_ACCESS error in CDVAccelerometer Message-Id: <20120518221532.C960916CA9@tyr.zones.apache.org> Date: Fri, 18 May 2012 22:15:32 +0000 (UTC) Fixed EXC_BAD_ACCESS error in CDVAccelerometer Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/24a007ad Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/24a007ad Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/24a007ad Branch: refs/heads/master Commit: 24a007ad31fc623e6674ee8aa9418481f343e2a0 Parents: d888bf3 Author: Shazron Abdullah Authored: Wed May 16 15:02:55 2012 -0700 Committer: Fil Maj Committed: Fri May 18 15:18:20 2012 -0700 ---------------------------------------------------------------------- CordovaLib/Classes/CDVAccelerometer.m | 31 ++++++++++++++------------- 1 files changed, 16 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/24a007ad/CordovaLib/Classes/CDVAccelerometer.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVAccelerometer.m b/CordovaLib/Classes/CDVAccelerometer.m index 51c0ae4..8f8d95b 100644 --- a/CordovaLib/Classes/CDVAccelerometer.m +++ b/CordovaLib/Classes/CDVAccelerometer.m @@ -48,8 +48,9 @@ y = 0; z = 0; timestamp = 0; - accelCallbacks = nil; - watchCallbacks = nil; + self.accelCallbacks = nil; + self.watchCallbacks = nil; + self.isRunning = NO; } return self; } @@ -65,13 +66,13 @@ UIAccelerometer* pAccel = [UIAccelerometer sharedAccelerometer]; // accelerometer expects fractional seconds, but we have msecs pAccel.updateInterval = desiredFrequency_num / 1000; - if (!accelCallbacks) { - accelCallbacks = [NSMutableArray arrayWithCapacity:1]; + if (!self.accelCallbacks) { + self.accelCallbacks = [NSMutableArray arrayWithCapacity:1]; } if (!watchCallbacks) { - watchCallbacks = [NSMutableDictionary dictionaryWithCapacity:1]; + self.watchCallbacks = [NSMutableDictionary dictionaryWithCapacity:1]; } - if(!_bIsRunning) + if(!self.isRunning) { pAccel.delegate = self; self.isRunning = YES; @@ -96,10 +97,10 @@ { CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT]; [result setKeepCallback:[NSNumber numberWithBool:YES]]; - if (!accelCallbacks) { - accelCallbacks = [NSMutableArray arrayWithCapacity:1]; + if (!self.accelCallbacks) { + self.accelCallbacks = [NSMutableArray arrayWithCapacity:1]; } - [accelCallbacks addObject:callbackId]; + [self.accelCallbacks addObject:callbackId]; [self start]; [self writeJavascript:[result toSuccessCallbackString:callbackId]]; } else { @@ -112,14 +113,14 @@ NSString* callbackId = [arguments objectAtIndex:0]; NSString* timerId = [arguments objectAtIndex:1]; - if (!watchCallbacks) { - watchCallbacks = [NSMutableDictionary dictionaryWithCapacity:1]; + if (!self.watchCallbacks) { + self.watchCallbacks = [NSMutableDictionary dictionaryWithCapacity:1]; } // add the callbackId into the dictionary so we can call back whenever get data - [watchCallbacks setObject:callbackId forKey:timerId]; + [self.watchCallbacks setObject:callbackId forKey:timerId]; - if (!_bIsRunning) { + if (!self.isRunning) { [self start]; } CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT]; @@ -130,8 +131,8 @@ { NSString* callbackId = [arguments objectAtIndex:0]; NSString* timerId = [arguments objectAtIndex:1]; - if (watchCallbacks && [watchCallbacks objectForKey:timerId]) { - [watchCallbacks removeObjectForKey:timerId]; + if (self.watchCallbacks && [self.watchCallbacks objectForKey:timerId]) { + [self.watchCallbacks removeObjectForKey:timerId]; } CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; NSString* jsString = [result toSuccessCallbackString:callbackId];