Re: @synchronized crashing with ARC

2012-05-31 Thread Jens Alfke
On May 31, 2012, at 8:59 PM, Antonio Nunes wrote: > Couldn't we just [[NSObject alloc] init]? I think @synchronized cares about > pointer uniqueness, not about the class, no? (And, as I learned from this, > under ARC the pointer should also actually respond to memory management > methods, i.e.

Re: @synchronized crashing with ARC

2012-05-31 Thread Charles Srstka
On May 31, 2012, at 10:59 PM, Antonio Nunes wrote: > On 1 Jun 2012, at 02:34, Charles Srstka wrote: > >> static dispatch_once_t onceToken; >> dispatch_once(&onceToken, ^{ >> myVLFContext = [[VLFContext alloc] init]; >> }); >> >> @synchronized(myVLFContext) { >> ... >> } > > That does

Re: @synchronized crashing with ARC

2012-05-31 Thread Antonio Nunes
On 1 Jun 2012, at 02:34, Charles Srstka wrote: > static dispatch_once_t onceToken; > dispatch_once(&onceToken, ^{ > myVLFContext = [[VLFContext alloc] init]; > }); > > @synchronized(myVLFContext) { > ... > } That does seem better. Any reason though to create a custom class? Couldn't

Re: @synchronized crashing with ARC

2012-05-31 Thread Charles Srstka
On May 31, 2012, at 3:28 PM, Lane Roathe wrote: > Suggestions: > > 1. remove the k prefix, by convention that is reserved for constants > > 2. don't use the same var name for a local variable as for a global variable > > 3. That should be something like: > > static VLFContext* myVLFContext = n

Re: @synchronized crashing with ARC

2012-05-31 Thread Jean-Daniel Dupas
Le 31 mai 2012 à 22:28, Lane Roathe a écrit : > > On May 31, 2012, at 2:00 PM, Jean-Daniel Dupas wrote: > >> Le 31 mai 2012 à 18:00, Jens Alfke a écrit : >> >>> On May 31, 2012, at 8:47 AM, Antonio Nunes wrote: >>> static void *kMyVLFContext = &kMyVLFContext; >>> ... @synchroni

Re: @synchronized crashing with ARC

2012-05-31 Thread Lane Roathe
On May 31, 2012, at 2:00 PM, Jean-Daniel Dupas wrote: > Le 31 mai 2012 à 18:00, Jens Alfke a écrit : > >> On May 31, 2012, at 8:47 AM, Antonio Nunes wrote: >> >>> static void *kMyVLFContext = &kMyVLFContext; >> ... >>> @synchronized(kMyVLFContext) { >> >> Huh? I thought the parameter to

Re: @synchronized crashing with ARC

2012-05-31 Thread Jean-Daniel Dupas
Le 31 mai 2012 à 18:00, Jens Alfke a écrit : > > On May 31, 2012, at 8:47 AM, Antonio Nunes wrote: > >> static void *kMyVLFContext = &kMyVLFContext; > ... >> @synchronized(kMyVLFContext) { > > Huh? I thought the parameter to @synchronized(…) had to be an object > reference? The Obj

Re: @synchronized crashing with ARC

2012-05-31 Thread Antonio Nunes
On 31 May 2012, at 17:00, Jens Alfke wrote: > Huh? I thought the parameter to @synchronized(…) had to be an object > reference? Well, yes, but my understanding was/is that it was essentially about the pointer, and this formula worked just fine until I migrated to ARC. I think Scott is right th

Re: @synchronized crashing with ARC

2012-05-31 Thread Antonio Nunes
On 31 May 2012, at 17:14, Scott A Andrew wrote: > My guess is that you are crashing because kMyVLFContext is not an objective C > object. According to the Apple documentation > (https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocThreading.html#//apple_

Re: @synchronized crashing with ARC

2012-05-31 Thread Jens Alfke
On May 31, 2012, at 8:47 AM, Antonio Nunes wrote: > static void *kMyVLFContext = &kMyVLFContext; ... > @synchronized(kMyVLFContext) { Huh? I thought the parameter to @synchronized(…) had to be an object reference? —Jens ___ Cocoa-dev maili

Re: @synchronized crashing with ARC

2012-05-31 Thread James Montgomerie
It looks a bit suspicious to me that you're instantiating the dictionary in your hidden "… work ..." code, then using it in the visible code, but not releasing it. Is it possible that the dictionary started out as an ObjC object that you don't own, and you used a (__bridge CFDictionaryRef) cast

Re: @synchronized crashing with ARC

2012-05-31 Thread Scott A Andrew
My guess is that you are crashing because kMyVLFContext is not an objective C object. According to the Apple documentation (https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocThreading.html#//apple_ref/doc/uid/TP30001163-CH19-SW1): The @synchronized() d

@synchronized crashing with ARC

2012-05-31 Thread Antonio Nunes
I have a function that looks essentially like this: static void *kMyVLFContext = &kMyVLFContext; Boolean myFunction(CFURLRef path) { CFDictionaryRef myDictionary = NULL; @synchronized(kMyVLFContext) { … work … } return myDictionary != NULL