I found a better solution which works in ARC mode

- (void)windowWillCloseNotifications:(NSNotification*) aNotification
{
    NSWindow* w = [aNotification object];

    if (w && [[(NSObject*)[w delegate] className] 
isEqualToString:@"QuartzCocoaView"]){
        [w setReleasedWhenClosed:NO];
    }

On Nov 13, 2013, at 2:28 PM, Randy Lai <[email protected]> wrote:

> an additional semi colon is the last post.
> 
> - (void)windowWillCloseNotifications:(NSNotification*) aNotification
> {
> 
>       NSWindow *w = [aNotification object];
> 
>    if (w && [[(NSObject*)[w delegate] className] 
> isEqualToString:@"QuartzCocoaView"])
>         [w retain];
> 
> On Nov 13, 2013, at 2:10 PM, Randy Lai <[email protected]> wrote:
> 
>> I figured it out. The window instance will be released in the main R, so we 
>> have to retain the instance until it is released.
>> Otherwise, the window will be released twice.
>> 
>> - (void)windowWillCloseNotifications:(NSNotification*) aNotification
>> {
>> 
>>      NSWindow *w = [aNotification object];
>> 
>>   if (w && [[(NSObject*)[w delegate] className] 
>> isEqualToString:@"QuartzCocoaView"]);
>>        [w retain];
>> 
>> 
>> On Nov 13, 2013, at 12:07 PM, Randy Lai <[email protected]> wrote:
>> 
>>> I meant the method windowWillCloseNotifications in RDocumentController.m
>>> 
>>> 1. change “QuartzCocoaView” to something otherwise to avoid it being 
>>> invoked,
>>> 2. compile the R GUI
>>> 3. run the plot function, e.g. plot(1,1)
>>> 4. close the quartz
>>> 
>>> you will see the error  EXC_HAD_ACCESS (code=EXC_i386_GPFLT).
>>> 
>>> there may be a memory leak in R code!?
>>> 
>>> 
>>> On Nov 13, 2013, at 6:26 AM, Simon Urbanek <[email protected]> 
>>> wrote:
>>> 
>>>> On Nov 13, 2013, at 6:54 AM, Randy Lai <[email protected]> wrote:
>>>> 
>>>>> Hi all,
>>>>> 
>>>>> I am studying the R GUI code and I have a question about Quartz.
>>>>> 
>>>>> It seems that R GUI will add a dummy Quartz Cocoa window before the 
>>>>> quartz is closed.
>>>>> What is the reason behind?
>>>>> 
>>>> 
>>>> Can you supply some details as of what you're looking at? The GUI is no 
>>>> longer driving Quartz, so I'm not sure what code you have in mind.
>>>> 
>>>> Cheers,
>>>> Simon
>>>> 
>>>> 
>>>> 
>>>> 
>>>>> I have tried compiled the code without this part, it raises an error for 
>>>>> EXC_HAD_ACCESS (code=EXC_i386_GPFLT).
>>>>> 
>>>>> Randy
>>>>> _______________________________________________
>>>>> R-SIG-Mac mailing list
>>>>> [email protected]
>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>>>> 
>>>> 
>>> 
>> 
> 

_______________________________________________
R-SIG-Mac mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to