[gnumeric] Exit: non-zero return code if we fail to load a file from command line
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Exit: non-zero return code if we fail to load a file from command line
- Date: Fri, 4 May 2018 16:12:54 +0000 (UTC)
commit 45ee7f5fa1fceb69275199b4f1e4f3ad01ddb238
Author: Morten Welinder <terra gnome org>
Date: Fri May 4 12:12:00 2018 -0400
Exit: non-zero return code if we fail to load a file from command line
NEWS | 1 +
src/main-application.c | 23 +++++++++++++++--------
2 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/NEWS b/NEWS
index 6b6e8d2..f68101f 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Gnumeric 1.12.41
Morten:
* Fix problem with object pasting.
* Fix undo problem for cell comments. [#732653]
+ * Exit with non-zero with we fail to load file on command line.
--------------------------------------------------------------------------
Gnumeric 1.12.40
diff --git a/src/main-application.c b/src/main-application.c
index a42b6e7..86ec06d 100644
--- a/src/main-application.c
+++ b/src/main-application.c
@@ -194,6 +194,7 @@ main (int argc, char const **argv)
WorkbookView *wbv;
GSList *wbcgs_to_kill = NULL;
GOCmdContext *cc;
+ gboolean any_error = FALSE;
#ifdef G_OS_WIN32
gboolean has_console;
@@ -265,6 +266,7 @@ main (int argc, char const **argv)
if (uri == NULL) {
g_warning ("Ignoring invalid URI.");
+ any_error = TRUE;
continue;
}
@@ -274,6 +276,8 @@ main (int argc, char const **argv)
if (go_io_error_occurred (ioc) ||
go_io_warning_occurred (ioc)) {
+ if (go_io_error_occurred (ioc))
+ any_error = TRUE;
go_io_error_display (ioc);
go_io_error_clear (ioc);
}
@@ -303,11 +307,17 @@ main (int argc, char const **argv)
g_object_unref (cc);
cc = NULL;
- /* FIXME: Maybe we should quit here if we were asked to open
- files and failed to do so. */
+ // If we actually opened a workbook, we are not about to exit so
+ // suppress the error. (Returning an error when the GUI exits
+ // down the line is not helpful.)
+ if (opened_workbook)
+ any_error = FALSE;
- /* If we were intentionally short circuited exit now */
- if (!initial_workbook_open_complete) {
+ // If we were intentionally short circuited exit now
+ if (any_error || initial_workbook_open_complete) {
+ g_object_unref (ioc);
+ g_slist_foreach (wbcgs_to_kill, (GFunc)cb_kill_wbcg, NULL);
+ } else {
initial_workbook_open_complete = TRUE;
if (!opened_workbook) {
gint n_of_sheets = gnm_conf_get_core_workbook_n_sheet ();
@@ -331,9 +341,6 @@ main (int argc, char const **argv)
g_object_unref (ioc);
gtk_main ();
- } else {
- g_object_unref (ioc);
- g_slist_foreach (wbcgs_to_kill, (GFunc)cb_kill_wbcg, NULL);
}
g_slist_free (wbcgs_to_kill);
@@ -369,5 +376,5 @@ main (int argc, char const **argv)
g_slist_free (displays);
}
- return 0;
+ return any_error ? 1 : 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]