Bug 578045 - [win32] FileDialog.setFilterPath in SWT does not work anymore
Summary: [win32] FileDialog.setFilterPath in SWT does not work anymore
Status: CLOSED DUPLICATE of bug 577190
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.21   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2022-01-04 08:11 EST by Erik Hentschke CLA
Modified: 2022-01-06 11:02 EST (History)
6 users (show)

See Also:


Attachments
Fix for initial folder in FileDialog.open() (920 bytes, patch)
2022-01-04 08:11 EST, Erik Hentschke CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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 ***