renamed batch_init() to batch_run(). Install an Gimp::exit handler while
2003-11-30 Sven Neumann <sven@gimp.org> * app/batch.[ch]: renamed batch_init() to batch_run(). Install an Gimp::exit handler while batch commands are executed. This handler simply calls exit(). Fixes bug #128199. * app/app_procs.c: changed accordingly. Removed remaining global variables.
This commit is contained in:

committed by
Sven Neumann

parent
4bb0464f4d
commit
0c99483df4
@ -1,3 +1,12 @@
|
|||||||
|
2003-11-30 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/batch.[ch]: renamed batch_init() to batch_run(). Install an
|
||||||
|
Gimp::exit handler while batch commands are executed. This handler
|
||||||
|
simply calls exit(). Fixes bug #128199.
|
||||||
|
|
||||||
|
* app/app_procs.c: changed accordingly. Removed remaining global
|
||||||
|
variables.
|
||||||
|
|
||||||
2003-11-30 Michael Natterer <mitch@gimp.org>
|
2003-11-30 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/paint/gimp-paint.c (gimp_paint_init): reordered
|
* app/paint/gimp-paint.c (gimp_paint_init): reordered
|
||||||
|
@ -64,16 +64,12 @@ static void app_init_update_none (const gchar *text1,
|
|||||||
const gchar *text2,
|
const gchar *text2,
|
||||||
gdouble percentage);
|
gdouble percentage);
|
||||||
static gboolean app_exit_after_callback (Gimp *gimp,
|
static gboolean app_exit_after_callback (Gimp *gimp,
|
||||||
gboolean kill_it);
|
gboolean kill_it,
|
||||||
|
GMainLoop *loop);
|
||||||
|
|
||||||
|
|
||||||
/* private variables */
|
/* private variables */
|
||||||
|
|
||||||
static Gimp *the_gimp = NULL;
|
|
||||||
static GMainLoop *loop = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -103,11 +99,13 @@ app_run (const gchar *full_prog_name,
|
|||||||
GimpStackTraceMode stack_trace_mode)
|
GimpStackTraceMode stack_trace_mode)
|
||||||
{
|
{
|
||||||
GimpInitStatusFunc update_status_func = NULL;
|
GimpInitStatusFunc update_status_func = NULL;
|
||||||
|
Gimp *gimp;
|
||||||
|
GMainLoop *loop;
|
||||||
|
|
||||||
/* Create an instance of the "Gimp" object which is the root of the
|
/* Create an instance of the "Gimp" object which is the root of the
|
||||||
* core object system
|
* core object system
|
||||||
*/
|
*/
|
||||||
the_gimp = gimp_new (full_prog_name,
|
gimp = gimp_new (full_prog_name,
|
||||||
session_name,
|
session_name,
|
||||||
be_verbose,
|
be_verbose,
|
||||||
no_data,
|
no_data,
|
||||||
@ -119,55 +117,55 @@ app_run (const gchar *full_prog_name,
|
|||||||
|
|
||||||
g_log_set_handler ("Gimp",
|
g_log_set_handler ("Gimp",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-Base",
|
g_log_set_handler ("Gimp-Base",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-Paint-Funcs",
|
g_log_set_handler ("Gimp-Paint-Funcs",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-Config",
|
g_log_set_handler ("Gimp-Config",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-Core",
|
g_log_set_handler ("Gimp-Core",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-PDB",
|
g_log_set_handler ("Gimp-PDB",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-Plug-In",
|
g_log_set_handler ("Gimp-Plug-In",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-File",
|
g_log_set_handler ("Gimp-File",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-XCF",
|
g_log_set_handler ("Gimp-XCF",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-Widgets",
|
g_log_set_handler ("Gimp-Widgets",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-Display",
|
g_log_set_handler ("Gimp-Display",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-Tools",
|
g_log_set_handler ("Gimp-Tools",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-Text",
|
g_log_set_handler ("Gimp-Text",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-Vectors",
|
g_log_set_handler ("Gimp-Vectors",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
g_log_set_handler ("Gimp-GUI",
|
g_log_set_handler ("Gimp-GUI",
|
||||||
G_LOG_LEVEL_MESSAGE,
|
G_LOG_LEVEL_MESSAGE,
|
||||||
gimp_message_log_func, &the_gimp);
|
gimp_message_log_func, &gimp);
|
||||||
|
|
||||||
g_log_set_handler (NULL,
|
g_log_set_handler (NULL,
|
||||||
G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL,
|
G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL,
|
||||||
gimp_error_log_func, &the_gimp);
|
gimp_error_log_func, &gimp);
|
||||||
|
|
||||||
units_init (the_gimp);
|
units_init (gimp);
|
||||||
|
|
||||||
/* Check if the user's gimp_directory exists
|
/* Check if the user's gimp_directory exists
|
||||||
*/
|
*/
|
||||||
@ -193,37 +191,30 @@ app_run (const gchar *full_prog_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_load_config (the_gimp, alternate_system_gimprc, alternate_gimprc);
|
gimp_load_config (gimp, alternate_system_gimprc, alternate_gimprc);
|
||||||
|
|
||||||
/* initialize lowlevel stuff */
|
/* initialize lowlevel stuff */
|
||||||
base_init (GIMP_BASE_CONFIG (the_gimp->config), use_cpu_accel);
|
base_init (GIMP_BASE_CONFIG (gimp->config), use_cpu_accel);
|
||||||
|
|
||||||
if (! no_interface)
|
if (! no_interface)
|
||||||
update_status_func = gui_init (the_gimp, no_splash, no_splash_image);
|
update_status_func = gui_init (gimp, no_splash, no_splash_image);
|
||||||
|
|
||||||
if (! update_status_func)
|
if (! update_status_func)
|
||||||
update_status_func = app_init_update_none;
|
update_status_func = app_init_update_none;
|
||||||
|
|
||||||
/* connect our "exit" callbacks after gui_init() so they are
|
|
||||||
* invoked after the GUI's "exit" callbacks
|
|
||||||
*/
|
|
||||||
g_signal_connect_after (the_gimp, "exit",
|
|
||||||
G_CALLBACK (app_exit_after_callback),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* Create all members of the global Gimp instance which need an already
|
/* Create all members of the global Gimp instance which need an already
|
||||||
* parsed gimprc, e.g. the data factories
|
* parsed gimprc, e.g. the data factories
|
||||||
*/
|
*/
|
||||||
gimp_initialize (the_gimp, update_status_func);
|
gimp_initialize (gimp, update_status_func);
|
||||||
|
|
||||||
/* Load all data files
|
/* Load all data files
|
||||||
*/
|
*/
|
||||||
gimp_restore (the_gimp, update_status_func);
|
gimp_restore (gimp, update_status_func);
|
||||||
|
|
||||||
/* enable autosave late so we don't autosave when the
|
/* enable autosave late so we don't autosave when the
|
||||||
* monitor resolution is set in gui_init()
|
* monitor resolution is set in gui_init()
|
||||||
*/
|
*/
|
||||||
gimp_rc_set_autosave (GIMP_RC (the_gimp->edit_config), TRUE);
|
gimp_rc_set_autosave (GIMP_RC (gimp->edit_config), TRUE);
|
||||||
|
|
||||||
/* Parse the rest of the command line arguments as images to load
|
/* Parse the rest of the command line arguments as images to load
|
||||||
*/
|
*/
|
||||||
@ -248,7 +239,7 @@ app_run (const gchar *full_prog_name,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uri = file_utils_filename_to_uri (the_gimp->load_procs,
|
uri = file_utils_filename_to_uri (gimp->load_procs,
|
||||||
gimp_argv[i], &error);
|
gimp_argv[i], &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +254,7 @@ app_run (const gchar *full_prog_name,
|
|||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpPDBStatusType status;
|
GimpPDBStatusType status;
|
||||||
|
|
||||||
gimage = file_open_with_display (the_gimp, uri,
|
gimage = file_open_with_display (gimp, uri,
|
||||||
&status, &error);
|
&status, &error);
|
||||||
|
|
||||||
if (! gimage && status != GIMP_PDB_CANCEL)
|
if (! gimage && status != GIMP_PDB_CANCEL)
|
||||||
@ -285,26 +276,32 @@ app_run (const gchar *full_prog_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
batch_init (the_gimp, batch_cmds);
|
batch_run (gimp, batch_cmds);
|
||||||
|
|
||||||
if (no_interface)
|
if (no_interface)
|
||||||
{
|
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
else
|
||||||
|
loop = NULL;
|
||||||
|
|
||||||
gimp_threads_leave (the_gimp);
|
g_signal_connect_after (gimp, "exit",
|
||||||
|
G_CALLBACK (app_exit_after_callback),
|
||||||
|
loop);
|
||||||
|
|
||||||
|
if (loop)
|
||||||
|
{
|
||||||
|
gimp_threads_leave (gimp);
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
gimp_threads_enter (the_gimp);
|
gimp_threads_enter (gimp);
|
||||||
|
|
||||||
g_main_loop_unref (loop);
|
g_main_loop_unref (loop);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gui_post_init (the_gimp);
|
gui_post_init (gimp);
|
||||||
|
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (the_gimp);
|
g_object_unref (gimp);
|
||||||
base_exit ();
|
base_exit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +317,8 @@ app_init_update_none (const gchar *text1,
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
app_exit_after_callback (Gimp *gimp,
|
app_exit_after_callback (Gimp *gimp,
|
||||||
gboolean kill_it)
|
gboolean kill_it,
|
||||||
|
GMainLoop *loop)
|
||||||
{
|
{
|
||||||
if (gimp->be_verbose)
|
if (gimp->be_verbose)
|
||||||
g_print ("EXIT: app_exit_after_callback\n");
|
g_print ("EXIT: app_exit_after_callback\n");
|
||||||
|
22
app/batch.c
22
app/batch.c
@ -37,6 +37,8 @@
|
|||||||
#include "pdb/procedural_db.h"
|
#include "pdb/procedural_db.h"
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean batch_exit_after_callback (Gimp *gimp,
|
||||||
|
gboolean kill_it);
|
||||||
static void batch_run_cmd (Gimp *gimp,
|
static void batch_run_cmd (Gimp *gimp,
|
||||||
const gchar *cmd);
|
const gchar *cmd);
|
||||||
static void batch_perl_server (Gimp *gimp,
|
static void batch_perl_server (Gimp *gimp,
|
||||||
@ -49,12 +51,17 @@ static ProcRecord *eval_proc = NULL;
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
batch_init (Gimp *gimp,
|
batch_run (Gimp *gimp,
|
||||||
const gchar **batch_cmds)
|
const gchar **batch_cmds)
|
||||||
{
|
{
|
||||||
gboolean perl_server_already_running = FALSE;
|
gboolean perl_server_already_running = FALSE;
|
||||||
|
gulong exit_id;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
|
exit_id = g_signal_connect_after (gimp, "exit",
|
||||||
|
G_CALLBACK (batch_exit_after_callback),
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (batch_cmds[0] && strcmp (batch_cmds[0], "-") == 0)
|
if (batch_cmds[0] && strcmp (batch_cmds[0], "-") == 0)
|
||||||
{
|
{
|
||||||
batch_cmds[0] = "(plug-in-script-fu-text-console RUN-INTERACTIVE)";
|
batch_cmds[0] = "(plug-in-script-fu-text-console RUN-INTERACTIVE)";
|
||||||
@ -94,8 +101,21 @@ batch_init (Gimp *gimp,
|
|||||||
|
|
||||||
batch_run_cmd (gimp, batch_cmds[i]);
|
batch_run_cmd (gimp, batch_cmds[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_signal_handler_disconnect (gimp, exit_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
batch_exit_after_callback (Gimp *gimp,
|
||||||
|
gboolean kill_it)
|
||||||
|
{
|
||||||
|
if (gimp->be_verbose)
|
||||||
|
g_print ("EXIT: batch_exit_after_callback\n");
|
||||||
|
|
||||||
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
batch_run_cmd (Gimp *gimp,
|
batch_run_cmd (Gimp *gimp,
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void batch_init (Gimp *gimp,
|
void batch_run (Gimp *gimp,
|
||||||
const gchar **batch_cmds);
|
const gchar **batch_cmds);
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user