bugGNUstep - Bugs: bug #25363, NSOpenPanel's delegate method...

Group
 
 

bug #25363: NSOpenPanel's delegate method panel:shouldShowFilename: is called too often

Submitter:  Doug Simons <theeggcamefirst>
Submitted:  Mon 19 Jan 2009 10:21:33 PM UTC
   
 
Category:  Gui/AppKit Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 15 Jun 2009 05:48:48 PM UTC, comment #6: 

Closed as there was no further response by the original author.

Fred Kiefer <FredKiefer>
Group Member
Sun 08 Feb 2009 10:23:10 PM UTC, comment #5: 

Okay, I agree that there is indeed a problem in GNUstep here. NSSavePanel and NSOpenPanel should always display the contents of the directory passed to -runModalForDirectory:... and -beginSheetForDirectory:... regardless of whether they are file packages or would be rejected by the delegate's validator. I've committed a corresponding patch to the trunk.

Doug, does this change fix your problem?


Wolfgang Lux <wlux>
Mon 26 Jan 2009 02:40:56 PM UTC, comment #4: 

There is, indeed, a fine line to walk between documented and tested  behavior. 

I agree that the application should not make assumptions about how often the delegate is called (indeed that was my first thought when I saw this bug) but, given that it works on Cocoa, it makes it, in the practical sense, difficult for people to port thier applications to GNUstep.

My philosophy is, if there is something that we can do to make it compatible we should do it so that future developers/users will have an easier time of porting.   Otherwise we will hear it over and over and over every time someone runs into an issue such as this.

GC

Gregory John Casamento <gcasa>
Group administrator
Sun 25 Jan 2009 07:28:56 PM UTC, comment #3: 

Gregory,

I fully agree with your comment that in general we should make GNUstep's behavior as close as possible to the OS X one. Yet, in this particular case I think that GNUstep already follows the documented behavior, namely to call the delegate method whenever a file is loaded into the browser. (Of course, the documented behavior is not always the implemented one.) The problem is that GNUstep's NSBrowser class simply validates all columns up to the visible ones whereas Apple apparently validates only the visible ones. There is an obvious patch to implement that behavior for GNUstep, but I'm not sure whether NSBrowser will gracefully handle the case that a visible path turns out to be invalid when the user scrolls left in the browser, nor that GNUstep's NSOpenPanel/NSSavePanel do.
Furthermore, it seems to me that the original program has a bug in the first place and that a "correct" program should not expect its delegate method to be called for only a particular set of path names.

Wolfgang Lux <wlux>
Sun 25 Jan 2009 05:29:49 PM UTC, comment #2: 

I believe the point here is that it should only get called for each file/directory in the current directory and not the ones beneath it in the entire tree.  

See the documentation at:
http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSSavePanel_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/panel:shouldShowFilename:

In the docs when and how often the delegate method is called is not defined.

In general we should, whenever possible/easy, make changes to bring GNUstep's behavior closer to Cocoa when we're made aware of a difference like this.

Thanks, GC

Gregory John Casamento <gcasa>
Group administrator
Sun 25 Jan 2009 01:48:07 PM UTC, comment #1: 

In fact, OS X calls -panel:shouldShowFilename: less frequently than GNUstep, and this certainly could be optimized. AFAIR OS X calls the delegate method only for the names that are visible in the Open Panel's browser. However this means if a user starts scrolling the browser to the left or selects a parent directory from the pop up, OS X should call the delegate method also with prefixes of /path/to/some/folder. So I think it is your program's fault to not handle these paths and not GNUstep's.

Wolfgang Lux <wlux>
Mon 19 Jan 2009 10:21:33 PM UTC, original submission:  

The NSOpenPanel (and NSSavePanel) delegate method panel:shouldShowFilename: is incorrectly called with subpaths as well as the final path. Cocoa doesn't do this.

For example, if I set the default directory to /path/to/some/folder, it seems that the delegate method gets called with "/", "/path", "/path/to", and "/path/to/some" as well as "/path/to/some/folder". I want to restrict use of the open panel to only allow opening files within that particular folder and its subfolders, so my implementation of this method (which worked under Cocoa) rejected paths that didn't begin with /path/to/some/folder. With GNUstep's behavior, my implementation is called first with "/" and rejects it, so the user isn't able to select anything.

Note: I had a hard time verifying exactly what Cocoa does, but it calls this method very seldom, and GS calls it a lot.


Doug Simons <theeggcamefirst>

 

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

Attach Files:
   
   
Comment:
   

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 FredKiefer (Posted a comment)
  • -email is unavailable- added by gcasa (Posted a comment)
  • -email is unavailable- added by wlux (Posted a comment)
  • -email is unavailable- added by theeggcamefirst (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.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-06-15 FredKiefer StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code