Avoid warnings about not checking chdir() result in wxGTK.
Give error if changing directory when wxFD_CHANGE_DIR or wxDIRP_CHANGE_DIR flags are used, this is a good idea generally speaking and it also avoids warnings about not checking chdir() return value that we got under Ubuntu. This is the backport of3f6741a770
from master with the changes ofcb06ecb9eb
andde27f4b08f
too.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#endif
|
||||
|
||||
@@ -81,7 +82,11 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
|
||||
{
|
||||
// Use chdir to not care about filename encodings
|
||||
wxGtkString folder(g_path_get_dirname(filename));
|
||||
chdir(folder);
|
||||
if ( chdir(folder) != 0 )
|
||||
{
|
||||
wxLogSysError(_("Changing current directory to \"%s\" failed"),
|
||||
wxString::FromUTF8(folder));
|
||||
}
|
||||
}
|
||||
|
||||
wxCommandEvent event(wxEVT_BUTTON, wxID_OK);
|
||||
|
@@ -18,6 +18,10 @@
|
||||
|
||||
#if wxUSE_FILEPICKERCTRL
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/log.h"
|
||||
#endif
|
||||
|
||||
#include "wx/filepicker.h"
|
||||
#include "wx/tooltip.h"
|
||||
|
||||
@@ -180,7 +184,13 @@ static void file_set(GtkFileChooser* widget, wxDirButton* p)
|
||||
// thus we need to make sure the current working directory is updated if wxDIRP_CHANGE_DIR
|
||||
// style was given.
|
||||
if (p->HasFlag(wxDIRP_CHANGE_DIR))
|
||||
chdir(filename);
|
||||
{
|
||||
if ( chdir(filename) != 0 )
|
||||
{
|
||||
wxLogSysError(_("Changing current directory to \"%s\" failed"),
|
||||
wxString::FromUTF8(filename));
|
||||
}
|
||||
}
|
||||
|
||||
// ...and fire an event
|
||||
wxFileDirPickerEvent event(wxEVT_DIRPICKER_CHANGED, p, p->GetId(), p->GetPath());
|
||||
|
Reference in New Issue
Block a user