None of the examples you pasted have anything to do with Apple’s garbage 
collector, hun. They’re just examples of advanced MRR. 

As I already stated, the viewer has never used Apple’s garbage collector. It 
uses a combination of autorelease pools and MRR which is perfectly fine to do, 
especially in Objective-C++ where we are not only managing objective-c objects, 
but C++ objects as well.
 
 
-- 
Cinder Roxley
Sent with Airmail
 

On July 8, 2016 at 1:47:16 PM, Geir Nøklebye (geir.nokle...@dayturn.com 
<mailto:geir.nokle...@dayturn.com> ) wrote:

 
Cinder Roxley said:
The viewer has never used the garbage collector so it?s not an issue.


Why is it that in llopenglview-objc.mm, as en example, we have statement like:

NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] 
initWithAttributes:attrs] autorelease];

or 

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}

while Apples ARC migration guidelines states:

You cannot explicitly invoke dealloc, or implement or invoke retain, release, 
retainCount, or autorelease.

You can’t invoke dealloc.

Custom dealloc methods in ARC do not require a call to [super dealloc] (it 
actually results in a compiler error). The chaining to super is automated and 
enforced by the compiler.


Or in llwindowmacosx-objc.mm we have code such as:

bool copyToPBoard(const unsigned short *str, unsigned int len)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
[pboard clearContents];

NSArray *contentsToPaste = [[NSArray alloc] initWithObjects:[NSString 
stringWithCharacters:str length:len], nil];
[pool release];
return [pboard writeObjects:contentsToPaste];
}

Apple’s documentation specifically says how to rewrite this construct for ARC. 

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSAutoreleasePool_Class/index.html#//apple_ref/occ/cl/NSAutoreleasePool


So all this code needs to be rewritten to support ARC or it will not run or 
fail on 10.12. 


Geir Nøklebye,

_______________________________________________
Policies and (un)subscribe information available here:
http://wiki.secondlife.com/wiki/OpenSource-Dev
Please read the policies before posting to keep unmoderated posting privileges

_______________________________________________
Policies and (un)subscribe information available here:
http://wiki.secondlife.com/wiki/OpenSource-Dev
Please read the policies before posting to keep unmoderated posting privileges

Reply via email to