sqweek / dialog

Simple cross-platform dialog API for go-lang
ISC License
493 stars 76 forks source link

fix: openfile changing program's working directory #65

Closed redraskal closed 2 years ago

redraskal commented 2 years ago

Fixes #63

The flag OFN_NOCHANGEDIR as seen at https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-openfilenamea will revert the working directory modification.

This also affected the Save() dialog fyi.

sqweek commented 2 years ago

Thanks! The docs for OFN_NOCHANGEDIR say:

This flag is ineffective for GetOpenFileName.

But my testing (under Windows 10) demonstrates that the current working directory is reset after closing the dialog when using this flag.

The working directory is however still changed while the dialog is open, which may affect other concurrent goroutines. However it doesn't look like there's a way to avoid this, short of avoiding the W32API in question.