Errors using wxFileDialog on LINUX Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
arwen
Knows some wx things
Knows some wx things
Posts: 37
Joined: Wed Aug 02, 2006 12:20 pm

Errors using wxFileDialog on LINUX

Post by arwen » Fri Oct 20, 2006 12:17 pm

I receive thi errors using wxFileDialog :
(Acquarius:4218): libgnomevfs-CRITICAL **: gnome_vfs_get_uri_from_local_path:assertion 'g_path_is_absolute (local_full_path)' failed
And so I fails to write file .
Below my function :
/****************************************************************************
* Mnusalva1011Click *
****************************************************************************
* Funzione per salvare i dati in un file *
****************************************************************************
*/
void AcquariusFrm::Mnusalva1011Click(wxCommandEvent& event)
{
wxTextFile file;
wxString caption = wxT("Seleziona un file");
wxString wildcard =wxT("ACQ File (*.acq)|*.acq");
wxString defaultDir = wxT("c:\\");
wxString defaultFilename = wxEmptyString;
wxFileDialog dialog(this,caption,defaultDir,defaultFilename,wildcard, wxSAVE);

if(dialog.ShowModal() == wxID_OK) {
// se il file esiste lo cancello
if (wxFile::Exists(dialog.GetPath())){
wxRemoveFile(dialog.GetPath());
file.Create(dialog.GetPath());
}else {
// Se non esiste lo creo
file.Create(dialog.GetPath());
}

file.Open(dialog.GetPath());
for ( int n = 0; n < WxGrid1->GetNumberRows(); ){
// Salva Data
file.AddLine(WxGrid1->GetCellValue(n,0));
// Salva PH
file.AddLine(WxGrid1->GetCellValue(n,1));
// Salva KH
file.AddLine(WxGrid1->GetCellValue(n,2));
// Salva Temp
file.AddLine(WxGrid1->GetCellValue(n,3));
// Salva NO
file.AddLine(WxGrid1->GetCellValue(n,4));
// Salva CO
file.AddLine(WxGrid1->GetCellValue(n,5));
// Salva Bolle
file.AddLine(WxGrid1->GetCellValue(n,6));
// Salva O
file.AddLine(WxGrid1->GetCellValue(n,7));
// Salva Litri
file.AddLine(WxGrid1->GetCellValue(n,9));
n++;
}
file.Write();
}
}
Some IDEA to solve ??

THANKS

User avatar
doublemax
Moderator
Moderator
Posts: 15273
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Fri Oct 20, 2006 12:45 pm

"c:\\" is not a valid path in Linux, try "/" instead when running on Linux
Use the source, Luke!

arwen
Knows some wx things
Knows some wx things
Posts: 37
Joined: Wed Aug 02, 2006 12:20 pm

Post by arwen » Fri Oct 20, 2006 2:35 pm

OOps !! :oops:

How I can know if I compiling on Linux or on windows

something like

#if LINUX
wxString defaultDir = wxT("/");
#end if

#if WINDOWS
wxString defaultDir = wxT("c:\\");
#end if

THANKS

Cursor
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Aug 29, 2004 3:09 pm
Location: Grenoble, France
Contact:

Post by Cursor » Fri Oct 20, 2006 5:37 pm

For a default path, I dont know, but you can easily use the default separator return by the static function wxFileName::GetPathSeparator.

http://www.wxwidgets.org/manuals/2.6.3/ ... hseparator
What is little and green, witch go up and down ??
Yoda playing with the force.

User avatar
doublemax
Moderator
Moderator
Posts: 15273
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Fri Oct 20, 2006 5:45 pm

Code: Select all

#if defined(__UNIX__)
  wxString defaultDir = wxT("/");
#endif

#if defined(__WINDOWS__)
  wxString defaultDir = wxT("c:\\\");
#endif 
Use the source, Luke!

arwen
Knows some wx things
Knows some wx things
Posts: 37
Joined: Wed Aug 02, 2006 12:20 pm

Post by arwen » Sat Oct 21, 2006 7:45 am

Thanks DoubleMax !!

:D :D :D :D :D

Post Reply