ofFileDialogResult brakes of ./../data path on Pc (solution proposed)

I am having a weird bug, that only appears on the pc version of the program

The bug is that (in the pc version) it doesn’t save the XML values

and this affects the image loading of images as well … (for some reason)

but the images I can work around them

the problem is in the xml and why is it that the pc version doesn’t work the same as with the mac verion… ?

I have a class that inherits 2 other classes

class button_par : public parath , public button {

ofImage asset2;



in cpp

button_par::button_par() :parathrhsh::parathrhsh() ,button::button(){



I have an ofxXmlSettings pointer and I pass a reference to it that I load from Setup() when I put values in the xml that is open in the heap it passes the values and it reads them

but when it comes the time to save and load again, it doesn’t save.

this problem is pc only…

not sure what I am doing wrong

in my mac I have the default Apple LLVM compiler 4.2

on my pc I have the GNU GCC

I have my src files in a google drive (it’s something like a cloud) and I link them

I write code on my mac and I compile it on pc without having to copy paste files etc.

just a little update on this weird issue…

at first I thought it was a bad pointer… I passed an xml pointer to a class and then that passed to another and then to another…

So I rewrote the code to not use pointers. but the problem remained…

bad guess.

Just to be clear… I am able to pass values on the xml and save them in other parts of the program and I’ve done this many times before both in the pc and mac versions, but

for some reason the following code and the following code only doesn’t work on the pc version


it doesn’t save the values to the xml

in the mac version I produce something like that in the xml:





but in the pc version nothing.

I recall having a similar problem on the iphone once, and when I changed the syntax of the string that saves the xml it worked…

in this case I tried a couple of variations but no luck yet.

OK it’s not the name of the xml path string either forget everything I said above!

I am making a new guess on what the bug is…

after trying many variations of the saving string and tested the paths in another pc program and made sure that they worked…

I realised… That I Use the

ofBeginSaveScreenAsPDF(saveFileResult.filePath+".pdf", true);  

ofSystemSaveDialog(“Weekly_”+ofGetTimestampString() + “” , “Save your file”);

in OSx it gives a path. on windows 8 it doesn’t.

and furthermore
After selecting a path it brakes the /…/data/ directory in OF.

OF doesn’t point to that path any more

thus not allowing to load images and save xml after calling the saveFileResult.filepath

any ideas on how to fix this?


OK I am 100% sure that this is the problem, I’ve tested the code without calling the

ofSystemSaveDialog function in the PC version and the XML saves and all the images load and in general the OF remembers where the OF data folder is.

So the problem lies in this Code inside


inside our ofSystemSaveDialog function

#ifdef TARGET_WIN32  
	wchar_t fileName[MAX_PATH] = L"";  
	char * extension;  
    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.lpstrTitle = L"Select Output File";  
	if (GetSaveFileNameW(&ofn)){  
		results.filePath = convertWideToNarrow(fileName);  

First of all I’ve noticed that we don’t pass the defaultName string that has the initial path that we give in

example :


in mac version we grab that string in the PC version we start from the directory that the program runs and when we select a different directory this brakes the data path that OF has in its memory (I put it in simple terms)

/////how do I know this is the problem:

at the begining of my program I call

This returns Path::current(); from Path.h

that string is the directory of where the program looks for files

When I call the ofSystemSaveDialog()
on the mac getCurrentWorkingDirectory(); still returns the original directory so when I try to load an image after using ofSystemSaveDialog it works.

(but on the pc version)

then ** cout<<getCurrentWorkingDirectory();** returns the place where I saved the file

for example c:\users\desktop

so the pc it later on the APP doesn’t save or load anything from the data directory and it returns the. Can’t load image “data/blabla/imag.png”

I tried copying getCurrentWorkingDirectory() to a string

and then pass it using **ofToDataPath(string, true/false);


but no luck yet


(anyway sorry about all the rumbling)


**How can we set the data path back to normal /…/data/ after we have finished saving to our location?

basically how can we set

Path::current(); from POCO back to the normal directory that we can grab from getCurrentWorkingDirectory() before using the ofSystemSaveDialog()?

something like: ofSetDataPathRoot(DEFAULT_DIRECTORY);


Ideally we should call this from inside ofSystemSaveDialog

but for now you can do this from within your testApp

string DEFAULT_DIRECTORY = ofToDataPath("",true);

and After


put a

This will allow you to be able to access your data path directory on a PC after you have used ofSystemSaveDialog();