mainGNUstep - Support: sr #106637, NSSavePanel/NSOpenPanel return an...

Group
 
 

You are not allowed to post comments on this tracker with your current authentication level.

sr #106637: NSSavePanel/NSOpenPanel return an instance variable instead of object copy

Submitter:  Riccardo Mottola <rmottola>
Submitted:  Thu 12 Feb 2009 11:33:58 PM UTC
   
 
Category:  AppKit Priority:  5 - Normal
Severity:  3 - Normal Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Operating System:  None

Fri 13 Feb 2009 06:06:18 AM UTC, comment #2: 

I guess we should change this, even though expecting the return value to persist is definitely an application programming error.

I don't think the current behavior could be called 'unexpected', given that documentation/tutorials about the OpenStep reference counting mechanism are generally very explicit about the fact that you need to retain values in case a subsequent call to a method destroys them.

Richard Frith-Macdonald <CaS>
Group Member
Thu 12 Feb 2009 11:48:24 PM UTC, comment #1: 

this is a bug not a sr

Riccardo Mottola <rmottola>
Group Member
Thu 12 Feb 2009 11:33:58 PM UTC, original submission:  

debugging the reason of easydiff Crashing while opening the second file to compare, I traced it to a problem with  [NSSavePanel directory]. That method returns just the instance variable _directory.

Since the second time the shared instance of the panel is gotten the internal variable gets ASSIGNed, the original object returned the first time gets released, and thus gets invalid.

even if this could be worked around in several ways in the applicatioin, I consider ths behaviour unexpected. I thus run the following test on the mac:

{
    NSOpenPanel *panel;
    NSString *dir;
   
    panel = [NSOpenPanel openPanel];
    dir = nil;
    [panel runModalForDirectory: dir file:nil types:nil];
    dir = [panel directory];
    panel = [NSOpenPanel openPanel];
    [panel runModalForDirectory: dir file:nil types:nil];
    NSLog(@"dir: %@", dir);
    NSLog(@"file: %@", [[panel filenames] objectAtIndex:0]);

}


and it works fine. thus I think gnustep should return an autoreleaed copy of the directory string.

Riccardo Mottola <rmottola>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by rmottola (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-02-12 rmottola StatusNone Invalid
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code