From 3f6741a770be745537affdae2a063e801f22ad8b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 12 Feb 2015 21:56:32 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78480 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/filedlg.cpp | 5 ++++- src/gtk/filepicker.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index e6f6320b86..95842c7743 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -81,7 +81,10 @@ 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")); + } } wxCommandEvent event(wxEVT_BUTTON, wxID_OK); diff --git a/src/gtk/filepicker.cpp b/src/gtk/filepicker.cpp index 3abea8d7cf..b3d777da3e 100644 --- a/src/gtk/filepicker.cpp +++ b/src/gtk/filepicker.cpp @@ -180,7 +180,12 @@ 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")); + } + } // ...and fire an event wxFileDirPickerEvent event(wxEVT_DIRPICKER_CHANGED, p, p->GetId(), p->GetPath());