[gnome-commander] Handle directory listing errors, show error message again
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Handle directory listing errors, show error message again
- Date: Sun, 11 Jul 2021 21:45:32 +0000 (UTC)
commit 8197490ea37785b3476e7f8fea0aaf0602979b91
Author: Uwe Scholz <u scholz83 gmx de>
Date: Wed Jul 7 10:41:10 2021 +0200
Handle directory listing errors, show error message again
src/dirlist.cc | 5 ++++-
src/gnome-cmd-dir.cc | 9 +++------
src/gnome-cmd-dir.h | 3 ++-
src/gnome-cmd-file-list.cc | 14 +++++++++++---
4 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/src/dirlist.cc b/src/dirlist.cc
index 0c847829..87ff3d9e 100644
--- a/src/dirlist.cc
+++ b/src/dirlist.cc
@@ -116,8 +116,11 @@ void sync_list (GnomeCmdDir *dir)
&error);
if(error)
{
+ dir->error = nullptr;
g_critical("sync_list: Unable to enumerate children, error: %s", error->message);
- g_error_free(error);
+ g_propagate_error(&(dir->error), error);
+ dir->state = GnomeCmdDir::STATE_EMPTY;
+ dir->done_func (dir, dir->gFileInfoList, dir->error);
return;
}
diff --git a/src/gnome-cmd-dir.cc b/src/gnome-cmd-dir.cc
index d31f8146..ce067ae8 100644
--- a/src/gnome-cmd-dir.cc
+++ b/src/gnome-cmd-dir.cc
@@ -223,7 +223,7 @@ static void gnome_cmd_dir_class_init (GnomeCmdDirClass *klass)
nullptr, nullptr,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE,
- 1, G_TYPE_INT);
+ 1, G_TYPE_POINTER);
object_class->finalize = gnome_cmd_dir_finalize;
klass->file_created = nullptr;
@@ -518,9 +518,7 @@ static void on_list_done (GnomeCmdDir *dir, GList *infolist, GError *error)
}
else if (dir->state == GnomeCmdDir::STATE_EMPTY)
{
- auto errorCode = g_enum_to_string (G_IO_ERROR, error->code);
- DEBUG('l', "File listing failed: %s\n", errorCode);
- g_free(errorCode);
+ DEBUG('l', "File listing failed: %s\n", error->message);
if (dir->dialog)
{
@@ -531,8 +529,7 @@ static void on_list_done (GnomeCmdDir *dir, GList *infolist, GError *error)
dir->priv->lock = FALSE;
DEBUG('l', "Emitting 'list-failed' signal\n");
- g_signal_emit (dir, signals[LIST_FAILED], 0, error->code);
- g_error_free(error);
+ g_signal_emit (dir, signals[LIST_FAILED], 0, dir->error);
}
}
diff --git a/src/gnome-cmd-dir.h b/src/gnome-cmd-dir.h
index df475307..f6ee2ac9 100644
--- a/src/gnome-cmd-dir.h
+++ b/src/gnome-cmd-dir.h
@@ -63,6 +63,7 @@ struct GnomeCmdDir
GnomeVFSAsyncHandle *list_handle;
gint list_counter;
State state;
+ GError *error;
DirListDoneFunc done_func;
@@ -80,7 +81,7 @@ struct GnomeCmdDirClass
void (* file_changed) (GnomeCmdDir *dir, GnomeCmdFile *file);
void (* file_renamed) (GnomeCmdDir *dir, GnomeCmdFile *file);
void (* list_ok) (GnomeCmdDir *dir, GList *files);
- void (* list_failed) (GnomeCmdDir *dir, GnomeVFSResult result);
+ void (* list_failed) (GnomeCmdDir *dir, GError *error);
};
struct GnomeCmdCon;
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index fc776f4a..11c53b5e 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -1620,12 +1620,20 @@ static gboolean set_home_connection (GnomeCmdFileList *fl)
}
-static void on_dir_list_failed (GnomeCmdDir *dir, GnomeVFSResult result, GnomeCmdFileList *fl)
+/**
+ * Handles an error which occured when directory listing failed.
+ * We expect that the error which should be reported is stored in the GnomeCmdDir object.
+ * The error location is freed afterwards.
+ */
+static void on_dir_list_failed (GnomeCmdDir *dir, gpointer *unused, GnomeCmdFileList *fl)
{
DEBUG('l', "on_dir_list_failed\n");
- if (result != GNOME_VFS_OK)
- gnome_cmd_show_message (nullptr, _("Directory listing failed."), gnome_vfs_result_to_string
(result));
+ if (dir->error)
+ {
+ gnome_cmd_show_message (nullptr, _("Directory listing failed."), dir->error->message);
+ g_clear_error(&(dir->error));
+ }
g_signal_handlers_disconnect_matched (fl->cwd, G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, fl);
fl->connected_dir = nullptr;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]