openframeworks / openframeworks/openFrameworks
ofSystemSaveDialog changes current directory on Windows only
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
Hi all, I noticed that when we use the ofSystemSaveDialog() function on PC
it changes the getCurrentWorkingDirectory() and this breaks the path directory in OF
So when you try to load an image or save an xml OF can't find the path because it looks to the directory you saved your files.
This only occurs under windows.
on Mac getCurrentWorkingDirectory() points to the same spot after the dialog
///
The problem is inside the ofSystemSaveDialog in the ofSystemUtils.cpp
#ifdef TARGET_WIN32
wchar_t fileName[MAX_PATH] = L"";
char * extension;
OPENFILENAMEW ofn;
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
HWND hwnd = WindowFromDC(wglGetCurrentDC());
ofn.hwndOwner = hwnd;
ofn.hInstance = GetModuleHandle(0);
ofn.nMaxFileTitle = 31;
ofn.lpstrFile = fileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = L"All Files (*.*)\0*.*\0";
ofn.lpstrDefExt = L""; // we could do .rxml here?
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
ofn.lpstrTitle = L"Select Output File";
if (GetSaveFileNameW(&ofn)){
results.filePath = convertWideToNarrow(fileName);
}
#endif
the way to deal with this now is after the
: saveFileResult.bSuccess or before you need to load or save something in data again.
you put once:
ofSetDataPathRoot(DEFAULT_DIRECTORY);
the DEFAULT_DIRECTORY is a string I initialize in setup with
DEFAULT_DIRECTORY = ofToDataPath("",true);
Not sure how we can solve this from within the function
related forum post:
http://forum.openframeworks.cc/index.php/topic,13382.msg57346.html#msg57346
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ofSystemUtils.cpp at the Windows implementation of ofSystemSaveDialog(), and reproduce the working-directory change on Windows. Verify that opening the dialog does not alter getCurrentWorkingDirectory(), then confirm image and XML paths still resolve afterward; no test file is mentioned in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100