unref the gimp object after dumping the configuration as a test for

2003-11-17  Sven Neumann  <sven@gimp.org>

	* app/main.c: unref the gimp object after dumping the
	configuration as a test for Gimp::finalize.

	* app/base/base.[ch]: keep a reference on the config object.
	Renamed parameter "use_mmx" to "use_cpu_accel".

	* app/core/gimp.[ch]: call base_init() and base_exit() from
	app_procs.c, not from the Gimp object.

	* app/app_procs.[ch]: renamed app_init() to app_run() since here's
	where the main loop is run. Actually quit the main loop in
	app_exit_after_callback() instead of just calling exit().

	* app/errors.[ch]: declared fatal error handlers as G_GNUC_NORETURN.

	* libgimp/gimp.h: fixed usage of G_GNUC_NORETURN.
This commit is contained in:
Sven Neumann 2003-11-17 00:17:01 +00:00 committed by Sven Neumann
parent 8462016ec5
commit 921f00c13d
12 changed files with 119 additions and 92 deletions

View file

@ -1,3 +1,22 @@
2003-11-17 Sven Neumann <sven@gimp.org>
* app/main.c: unref the gimp object after dumping the
configuration as a test for Gimp::finalize.
* app/base/base.[ch]: keep a reference on the config object.
Renamed parameter "use_mmx" to "use_cpu_accel".
* app/core/gimp.[ch]: call base_init() and base_exit() from
app_procs.c, not from the Gimp object.
* app/app_procs.[ch]: renamed app_init() to app_run() since here's
where the main loop is run. Actually quit the main loop in
app_exit_after_callback() instead of just calling exit().
* app/errors.[ch]: declared fatal error handlers as G_GNUC_NORETURN.
* libgimp/gimp.h: fixed usage of G_GNUC_NORETURN.
2003-11-16 Henrik Brix Andersen <brix@gimp.org> 2003-11-16 Henrik Brix Andersen <brix@gimp.org>
* app/config/gimpguiconfig.c (DEFAULT_WEB_BROWSER): changed * app/config/gimpguiconfig.c (DEFAULT_WEB_BROWSER): changed

View file

@ -38,6 +38,8 @@
#include "config/gimprc.h" #include "config/gimprc.h"
#include "base/base.h"
#include "core/gimp.h" #include "core/gimp.h"
#include "file/file-open.h" #include "file/file-open.h"
@ -68,6 +70,8 @@ static gboolean app_exit_after_callback (Gimp *gimp,
/* private variables */ /* private variables */
static Gimp *the_gimp = NULL; static Gimp *the_gimp = NULL;
static GMainLoop *loop = NULL;
/* public functions */ /* public functions */
@ -80,7 +84,7 @@ app_gui_libs_init (gint *argc,
} }
void void
app_init (const gchar *full_prog_name, app_run (const gchar *full_prog_name,
gint gimp_argc, gint gimp_argc,
gchar **gimp_argv, gchar **gimp_argv,
const gchar *alternate_system_gimprc, const gchar *alternate_system_gimprc,
@ -94,7 +98,7 @@ app_init (const gchar *full_prog_name,
gboolean no_splash_image, gboolean no_splash_image,
gboolean be_verbose, gboolean be_verbose,
gboolean use_shm, gboolean use_shm,
gboolean use_mmx, gboolean use_cpu_accel,
gboolean console_messages, gboolean console_messages,
GimpStackTraceMode stack_trace_mode) GimpStackTraceMode stack_trace_mode)
{ {
@ -201,10 +205,10 @@ app_init (const gchar *full_prog_name,
} }
} }
gimp_load_config (the_gimp, gimp_load_config (the_gimp, alternate_system_gimprc, alternate_gimprc);
alternate_system_gimprc,
alternate_gimprc, /* initialize lowlevel stuff */
use_mmx); base_init (GIMP_BASE_CONFIG (the_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 (the_gimp, no_splash, no_splash_image);
@ -297,8 +301,6 @@ app_init (const gchar *full_prog_name,
if (no_interface) if (no_interface)
{ {
GMainLoop *loop;
loop = g_main_loop_new (NULL, FALSE); loop = g_main_loop_new (NULL, FALSE);
gimp_threads_leave (the_gimp); gimp_threads_leave (the_gimp);
@ -313,6 +315,9 @@ app_init (const gchar *full_prog_name,
gtk_main (); gtk_main ();
} }
g_object_unref (the_gimp);
base_exit ();
} }
@ -332,13 +337,10 @@ app_exit_after_callback (Gimp *gimp,
if (gimp->be_verbose) if (gimp->be_verbose)
g_print ("EXIT: app_exit_after_callback\n"); g_print ("EXIT: app_exit_after_callback\n");
g_object_unref (gimp); if (loop)
the_gimp = NULL; g_main_loop_quit (loop);
else
/* There used to be foo_main_quit() here, but there's a chance gtk_main_quit ();
* that foo_main() was never called before we reach this point. --Sven
*/
exit (0);
return FALSE; return FALSE;
} }

View file

@ -28,7 +28,7 @@
gboolean app_gui_libs_init (gint *gimp_argc, gboolean app_gui_libs_init (gint *gimp_argc,
gchar ***gimp_argv); gchar ***gimp_argv);
void app_init (const gchar *full_prog_name, void app_run (const gchar *full_prog_name,
gint gimp_argc, gint gimp_argc,
gchar **gimp_argv, gchar **gimp_argv,
const gchar *alternate_system_gimprc, const gchar *alternate_system_gimprc,
@ -42,7 +42,7 @@ void app_init (const gchar *full_prog_name,
gboolean no_splash_image, gboolean no_splash_image,
gboolean be_verbose, gboolean be_verbose,
gboolean use_shm, gboolean use_shm,
gboolean use_mmx, gboolean use_cpu_accel,
gboolean console_messages, gboolean console_messages,
GimpStackTraceMode stack_trace_mode); GimpStackTraceMode stack_trace_mode);

View file

@ -60,7 +60,7 @@ static void base_tile_cache_size_notify (GObject *config,
void void
base_init (GimpBaseConfig *config, base_init (GimpBaseConfig *config,
gboolean use_mmx) gboolean use_cpu_accel)
{ {
gchar *swapfile; gchar *swapfile;
gchar *swapdir; gchar *swapdir;
@ -69,7 +69,7 @@ base_init (GimpBaseConfig *config,
g_return_if_fail (GIMP_IS_BASE_CONFIG (config)); g_return_if_fail (GIMP_IS_BASE_CONFIG (config));
g_return_if_fail (base_config == NULL); g_return_if_fail (base_config == NULL);
base_config = config; base_config = g_object_ref (config);
tile_cache_init (config->tile_cache_size); tile_cache_init (config->tile_cache_size);
@ -95,14 +95,17 @@ base_init (GimpBaseConfig *config,
g_free (path); g_free (path);
/* FIXME: pass use_cpu_accel to GimpComposite */
gimp_composite_init (); gimp_composite_init ();
paint_funcs_setup (use_mmx); paint_funcs_setup (use_cpu_accel);
} }
void void
base_exit (void) base_exit (void)
{ {
g_return_if_fail (base_config != NULL);
swapping_free (); swapping_free ();
paint_funcs_free (); paint_funcs_free ();
tile_swap_exit (); tile_swap_exit ();
@ -112,6 +115,7 @@ base_exit (void)
base_tile_cache_size_notify, base_tile_cache_size_notify,
NULL); NULL);
g_object_unref (base_config);
base_config = NULL; base_config = NULL;
} }

View file

@ -20,7 +20,7 @@
#define __BASE_H__ #define __BASE_H__
void base_init (GimpBaseConfig *config, void base_init (GimpBaseConfig *config,
gboolean use_mmx); gboolean use_cpu_accel);
void base_exit (void); void base_exit (void);

View file

@ -31,8 +31,6 @@
#include "config/gimpconfig-path.h" #include "config/gimpconfig-path.h"
#include "config/gimprc.h" #include "config/gimprc.h"
#include "base/base.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
#include "pdb/internal_procs.h" #include "pdb/internal_procs.h"
@ -479,8 +477,6 @@ gimp_finalize (GObject *object)
if (gimp->user_units) if (gimp->user_units)
gimp_units_exit (gimp); gimp_units_exit (gimp);
base_exit ();
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -819,8 +815,7 @@ gimp_edit_config_notify (GObject *edit_config,
void void
gimp_load_config (Gimp *gimp, gimp_load_config (Gimp *gimp,
const gchar *alternate_system_gimprc, const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc, const gchar *alternate_gimprc)
gboolean use_cpu_accel)
{ {
GimpRc *gimprc; GimpRc *gimprc;
@ -840,9 +835,6 @@ gimp_load_config (Gimp *gimp,
alternate_gimprc, alternate_gimprc,
gimp->be_verbose); gimp->be_verbose);
/* initialize lowlevel stuff */
base_init (GIMP_BASE_CONFIG (gimprc), use_cpu_accel);
gimp->config = GIMP_CORE_CONFIG (gimprc); gimp->config = GIMP_CORE_CONFIG (gimprc);
gimp->edit_config = gimp_config_duplicate (GIMP_CONFIG (gimp->config)); gimp->edit_config = gimp_config_duplicate (GIMP_CONFIG (gimp->config));

View file

@ -220,8 +220,7 @@ Gimp * gimp_new (const gchar *name,
void gimp_load_config (Gimp *gimp, void gimp_load_config (Gimp *gimp,
const gchar *alternate_system_gimprc, const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc, const gchar *alternate_gimprc);
gboolean use_cpu_accel);
void gimp_initialize (Gimp *gimp, void gimp_initialize (Gimp *gimp,
GimpInitStatusFunc status_callback); GimpInitStatusFunc status_callback);
void gimp_restore (Gimp *gimp, void gimp_restore (Gimp *gimp,

View file

@ -50,7 +50,7 @@ static gchar *full_prog_name = NULL;
/* local function prototypes */ /* local function prototypes */
static void gimp_eek (const gchar *reason, static G_GNUC_NORETURN void gimp_eek (const gchar *reason,
const gchar *message, const gchar *message,
gboolean use_handler); gboolean use_handler);

View file

@ -35,12 +35,12 @@ void gimp_message_log_func (const gchar *log_domain,
void gimp_error_log_func (const gchar *domain, void gimp_error_log_func (const gchar *domain,
GLogLevelFlags flags, GLogLevelFlags flags,
const gchar *message, const gchar *message,
gpointer data); gpointer data) G_GNUC_NORETURN;
void gimp_fatal_error (const gchar *message, void gimp_fatal_error (const gchar *message,
...); ...) G_GNUC_NORETURN ;
void gimp_terminate (const gchar *message, void gimp_terminate (const gchar *message,
...); ...) G_GNUC_NORETURN;
#endif /* __ERRORS_H__ */ #endif /* __ERRORS_H__ */

View file

@ -57,14 +57,14 @@
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <windows.h> #include <windows.h>
#else #else
static void gimp_sigfatal_handler (gint sig_num); static void gimp_sigfatal_handler (gint sig_num) G_GNUC_NORETURN;
static void gimp_sigchld_handler (gint sig_num); static void gimp_sigchld_handler (gint sig_num);
#endif #endif
static void gimp_show_version (void); static void gimp_show_version (void);
static void gimp_show_help (const gchar *progname); static void gimp_show_help (const gchar *progname);
static void gimp_text_console_exit (gint status); static void gimp_text_console_exit (gint status) G_GNUC_NORETURN;
/* /*
@ -177,6 +177,7 @@ main (int argc,
if (format) if (format)
{ {
Gimp *gimp; Gimp *gimp;
gboolean success;
g_type_init (); g_type_init ();
@ -184,8 +185,11 @@ main (int argc,
units_init (gimp); units_init (gimp);
gimp_text_console_exit (gimp_config_dump (format) ? success = gimp_config_dump (format);
EXIT_SUCCESS : EXIT_FAILURE);
g_object_unref (gimp);
gimp_text_console_exit (success ? EXIT_SUCCESS : EXIT_FAILURE);
} }
} }
} }
@ -436,7 +440,7 @@ main (int argc,
use_debug_handler, use_debug_handler,
stack_trace_mode); stack_trace_mode);
app_init (full_prog_name, app_run (full_prog_name,
argc - 1, argc - 1,
argv + 1, argv + 1,
alternate_system_gimprc, alternate_system_gimprc,

View file

@ -172,6 +172,13 @@ all other GIMP Library headers.
@Returns: @Returns:
<!-- ##### FUNCTION gimp_quit ##### -->
<para>
</para>
<!-- ##### FUNCTION gimp_install_procedure ##### --> <!-- ##### FUNCTION gimp_install_procedure ##### -->
<para> <para>

View file

@ -212,7 +212,7 @@ gint gimp_main (const GimpPlugInInfo *info,
/* Forcefully causes the gimp library to exit and /* Forcefully causes the gimp library to exit and
* close down its connection to main gimp application. * close down its connection to main gimp application.
*/ */
void G_GNUC_NORETURN gimp_quit (void); void gimp_quit (void) G_GNUC_NORETURN;
/* Install a procedure in the procedure database. /* Install a procedure in the procedure database.