Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#11866 closed defect (fixed)

wxFD_DEFAULT_STYLE

Reported by: troelsk Owned by:
Priority: normal Milestone:
Component: GUI-generic Version: stable-latest
Keywords: wxFileDialog wxFileSelectorEx wxFD_DEFAULT_STYLE wxDocManager Cc:
Blocked By: Blocking:
Patch: yes

Description

The wxID_OPEN menu handler in wxDocManager ends up calling wxFileSelectorEx - without the wxFD_FILE_MUST_EXIST flag: the file dialog then accepts all and any text typed in. This is rather unconventional use of the file dialog.
The problem can be seen in the docview samples.

The problem comes down to the wxFD_DEFAULT_STYLE definition,
#define wxFD_DEFAULT_STYLE wxFD_OPEN
Rather odd that it isn't like this
#define wxFD_DEFAULT_STYLE (wxFD_OPEN | wxFD_FILE_MUST_EXIST)

Attachments:

  • One patch fixing wxFD_DEFAULT_STYLE
  • Another patch with a workaround in wxDocManager, if the wxFD_DEFAULT_STYLE definition for some reason is not to be changed.

Same problem exists in the stable branch.

Attachments (3)

filedlg-default-style.patch download (462 bytes) - added by troelsk 10 years ago.
wxFD_DEFAULT_STYLE
docview-fileopen.patch download (673 bytes) - added by troelsk 10 years ago.
wxDocManager
filedlg-default-style2.patch download (631 bytes) - added by troelsk 10 years ago.
#2

Download all attachments as: .zip

Change History (6)

Changed 10 years ago by troelsk

wxFD_DEFAULT_STYLE

Changed 10 years ago by troelsk

wxDocManager

comment:1 Changed 10 years ago by vadz

  • Status changed from new to confirmed

I think changing wxFS_DEFAULT_STYLE is not a good idea as it would silently break any implementation of New... or Create... menu commands not specifying the style explicitly. I'll apply the second patch however, there is really no reason to AFAICS.

Thanks!

comment:2 Changed 10 years ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [63784]) Only allow opening existing files in docview framework.

Use wxFD_FILE_MUST_EXIST when asking the user for the name of the file to
open.

Closes #11866.

comment:3 Changed 10 years ago by troelsk

Thanks!
Unfortunately many more users are bound to be bitten by this.
Please consider applying patch #2, to at least make it more obvious what is going on.

Changed 10 years ago by troelsk

#2

Note: See TracTickets for help on using tickets.