mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Handle error of mc main loop.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
bb1e8f0e37
commit
176ae14711
@ -3319,7 +3319,7 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
|
||||
if ((error != 0) || (dview_dlg->state == DLG_CLOSED))
|
||||
destroy_dlg (dview_dlg);
|
||||
|
||||
return error;
|
||||
return error == 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -3412,8 +3412,8 @@ dview_diff_cmd (void)
|
||||
g_free (file1);
|
||||
g_free (file0);
|
||||
|
||||
if (rv != 0)
|
||||
message (1, MSG_ERROR, _("Two files are needed to compare"));
|
||||
if (rv == 0)
|
||||
message (D_ERROR, MSG_ERROR, _("Two files are needed to compare"));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -936,32 +936,38 @@ prepend_cwd_on_local (const char *filename)
|
||||
/** Invoke the internal view/edit routine with:
|
||||
* the default processing and forcing the internal viewer/editor
|
||||
*/
|
||||
static void
|
||||
static gboolean
|
||||
mc_maybe_editor_or_viewer (void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
switch (mc_global.mc_run_mode)
|
||||
{
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
case MC_RUN_EDITOR:
|
||||
edit_file (mc_run_param0, mc_args__edit_start_line);
|
||||
ret = edit_file (mc_run_param0, mc_args__edit_start_line);
|
||||
break;
|
||||
#endif /* USE_INTERNAL_EDIT */
|
||||
case MC_RUN_VIEWER:
|
||||
{
|
||||
char *path;
|
||||
|
||||
path = prepend_cwd_on_local (mc_run_param0);
|
||||
view_file (path, 0, 1);
|
||||
g_free (path);
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
#ifdef USE_DIFF_VIEW
|
||||
case MC_RUN_DIFFVIEWER:
|
||||
diff_view (mc_run_param0, mc_run_param1, mc_run_param0, mc_run_param1);
|
||||
ret = diff_view (mc_run_param0, mc_run_param1, mc_run_param0, mc_run_param1);
|
||||
break;
|
||||
#endif /* USE_DIFF_VIEW */
|
||||
default:
|
||||
break;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return (ret != 0);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1629,9 +1635,11 @@ quiet_quit_cmd (void)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/** Run the main dialog that occupies the whole screen */
|
||||
void
|
||||
gboolean
|
||||
do_nc (void)
|
||||
{
|
||||
gboolean ret;
|
||||
|
||||
dlg_colors_t midnight_colors;
|
||||
|
||||
midnight_colors[DLG_COLOR_NORMAL] = mc_skin_color_get ("dialog", "_default_");
|
||||
@ -1654,10 +1662,11 @@ do_nc (void)
|
||||
|
||||
/* Check if we were invoked as an editor or file viewer */
|
||||
if (mc_global.mc_run_mode != MC_RUN_FULL)
|
||||
mc_maybe_editor_or_viewer ();
|
||||
ret = mc_maybe_editor_or_viewer ();
|
||||
else
|
||||
{
|
||||
create_panels_and_run_mc ();
|
||||
ret = TRUE;
|
||||
|
||||
/* destroy_dlg destroys even current_panel->cwd, so we have to save a copy :) */
|
||||
if (mc_args__last_wd_file != NULL && vfs_current_is_local ())
|
||||
@ -1682,6 +1691,8 @@ do_nc (void)
|
||||
|
||||
if ((quit & SUBSHELL_EXIT) == 0)
|
||||
clr_scr ();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -45,7 +45,7 @@ void load_hint (gboolean force);
|
||||
void change_panel (void);
|
||||
void save_cwds_stat (void);
|
||||
gboolean quiet_quit_cmd (void);
|
||||
void do_nc (void);
|
||||
gboolean do_nc (void);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
|
11
src/main.c
11
src/main.c
@ -518,8 +518,10 @@ main (int argc, char *argv[])
|
||||
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
||||
|
||||
/* Program main loop */
|
||||
if (!mc_global.widget.midnight_shutdown)
|
||||
do_nc ();
|
||||
if (mc_global.widget.midnight_shutdown)
|
||||
exit_code = EXIT_SUCCESS;
|
||||
else
|
||||
exit_code = do_nc () ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
|
||||
/* Save the tree store */
|
||||
(void) tree_store_save ();
|
||||
@ -591,17 +593,16 @@ main (int argc, char *argv[])
|
||||
mc_config_deinit_config_paths ();
|
||||
|
||||
(void) mc_event_deinit (&error);
|
||||
|
||||
if (error != NULL)
|
||||
{
|
||||
fprintf (stderr, _("\nFailed while close:\n%s\n"), error->message);
|
||||
g_error_free (error);
|
||||
exit (EXIT_FAILURE);
|
||||
exit_code = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
(void) putchar ('\n'); /* Hack to make shell's prompt start at left of screen */
|
||||
|
||||
return 0;
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user