Bug 578045

Summary: [win32] FileDialog.setFilterPath in SWT does not work anymore
Product: [Eclipse Project] Platform Reporter: Erik Hentschke <erik.hentschke>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: digga1404, felix.hirsch, loskutov, nikita, p.beauvoir, rolf.theunissen
Version: 4.21Keywords: regression
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=571571
Whiteboard:
Attachments:
Description Flags
Fix for initial folder in FileDialog.open() none

Description Erik Hentschke CLA 2022-01-04 08:11:31 EST
Created attachment 287773 [details]
Fix for initial folder in FileDialog.open()

Hi,
after updating our application to Eclipse 2021-09 the setFilterPath does not work anymore. The directory used by the dialog seems to be random. 

I found out that this is probably caused by bug 571571. 

A fix could be adding fileDialog.ClearClientData() before calling fileDialog.SetDefaultFolder(psi) in FileDialog.open():

/* Set initial folder */
if (filterPath != null) {
   char[] path = (filterPath.replace('/', '\\') +"\0").toCharArray();
   if (COM.SHCreateItemFromParsingName(path, 0, COM.IID_IShellItem,ppv) == COM.S_OK)
   {
     IShellItem psi = new IShellItem(ppv[0])
     /*
      * SetDefaultFolder does not work if the dialog has
      * persisted recently used folder. The fix is to clear the
      * persisted data.
      */
     fileDialog.ClearClientData();
     fileDialog.SetDefaultFolder(psi); 
     psi.Release();
   }
}

I found this by comparing FileDialog with DirectoryDialog as mentioned in this stackoverflow question: 

https://stackoverflow.com/questions/18058575/set-the-initial-directory-in-swt-filedialog
Comment 1 Andrey Loskutov CLA 2022-01-04 08:16:04 EST
@Nikita, could you please check?
Comment 2 Phil Beauvoir CLA 2022-01-04 08:39:50 EST
Confirmed not working in 2012-12. Directory is not the one set in setFilterPath
Comment 3 Rolf Theunissen CLA 2022-01-06 02:54:07 EST

*** This bug has been marked as a duplicate of bug 577190 ***