diff --git a/ChangeLog b/ChangeLog index 1814e725ab..5ee85f6126 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2006-11-02 Michael Natterer + + Don't let each terminating plug-in procedure end its progress, + because that progress may still be in use by another plug-in. + + * app/plug-in/gimpplugin-progress.[ch] + (gimp_plug_in_progress_attach) + (gimp_plug_in_progress_detach): new functions which maintain + a simple attach count for a GimpProgress + + * app/plug-in/gimpplugin-progress.c + * app/plug-in/gimppluginprocframe.c: call attach() when setting + proc_frame->progress. Call detach() in gimp_plug_in_progress_end() + and only call gimp_progress_end() if detaching lowered the attach + count to 0. + 2006-11-02 Sven Neumann * plug-ins/common/flarefx.c (flare_center_create) diff --git a/app/plug-in/gimpplugin-progress.c b/app/plug-in/gimpplugin-progress.c index 6c60aeda41..76f16a64ab 100644 --- a/app/plug-in/gimpplugin-progress.c +++ b/app/plug-in/gimpplugin-progress.c @@ -45,6 +45,44 @@ static void gimp_plug_in_progress_cancel_callback (GimpProgress *progress, /* public functions */ +gint +gimp_plug_in_progress_attach (GimpProgress *progress) +{ + gint attach_count; + + g_return_val_if_fail (GIMP_IS_PROGRESS (progress), 0); + + attach_count = + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (progress), + "plug-in-progress-attach-count")); + + attach_count++; + + g_object_set_data (G_OBJECT (progress), "plug-in-progress-attach-count", + GINT_TO_POINTER (attach_count));; + + return attach_count; +} + +gint +gimp_plug_in_progress_detach (GimpProgress *progress) +{ + gint attach_count; + + g_return_val_if_fail (GIMP_IS_PROGRESS (progress), 0); + + attach_count = + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (progress), + "plug-in-progress-attach-count")); + + attach_count--; + + g_object_set_data (G_OBJECT (progress), "plug-in-progress-attach-count", + GINT_TO_POINTER (attach_count));; + + return attach_count; +} + void gimp_plug_in_progress_start (GimpPlugIn *plug_in, const gchar *message, @@ -67,6 +105,8 @@ gimp_plug_in_progress_start (GimpPlugIn *plug_in, proc_frame->progress_created = TRUE; g_object_ref (proc_frame->progress); + + gimp_plug_in_progress_attach (proc_frame->progress); } } @@ -113,7 +153,8 @@ gimp_plug_in_progress_end (GimpPlugIn *plug_in) proc_frame->progress_cancel_id = 0; } - if (gimp_progress_is_active (proc_frame->progress)) + if (gimp_plug_in_progress_detach (proc_frame->progress) < 1 && + gimp_progress_is_active (proc_frame->progress)) gimp_progress_end (proc_frame->progress); if (proc_frame->progress_created) @@ -237,6 +278,8 @@ gimp_plug_in_progress_install (GimpPlugIn *plug_in, "callback-name", progress_callback, NULL); + gimp_plug_in_progress_attach (proc_frame->progress); + return TRUE; } diff --git a/app/plug-in/gimpplugin-progress.h b/app/plug-in/gimpplugin-progress.h index 81f4ad0993..1707ba7968 100644 --- a/app/plug-in/gimpplugin-progress.h +++ b/app/plug-in/gimpplugin-progress.h @@ -22,23 +22,26 @@ #define __GIMP_PLUG_IN_PROGRESS_H__ -void gimp_plug_in_progress_start (GimpPlugIn *plug_in, - const gchar *message, - GimpObject *display); -void gimp_plug_in_progress_end (GimpPlugIn *plug_in); -void gimp_plug_in_progress_set_text (GimpPlugIn *plug_in, - const gchar *message); -void gimp_plug_in_progress_set_value (GimpPlugIn *plug_in, - gdouble percentage); -void gimp_plug_in_progress_pulse (GimpPlugIn *plug_in); -guint32 gimp_plug_in_progress_get_window (GimpPlugIn *plug_in); +gint gimp_plug_in_progress_attach (GimpProgress *progress); +gint gimp_plug_in_progress_detach (GimpProgress *progress); -gboolean gimp_plug_in_progress_install (GimpPlugIn *plug_in, - const gchar *progress_callback); -gboolean gimp_plug_in_progress_uninstall (GimpPlugIn *plug_in, - const gchar *progress_callback); -gboolean gimp_plug_in_progress_cancel (GimpPlugIn *plug_in, - const gchar *progress_callback); +void gimp_plug_in_progress_start (GimpPlugIn *plug_in, + const gchar *message, + GimpObject *display); +void gimp_plug_in_progress_end (GimpPlugIn *plug_in); +void gimp_plug_in_progress_set_text (GimpPlugIn *plug_in, + const gchar *message); +void gimp_plug_in_progress_set_value (GimpPlugIn *plug_in, + gdouble percentage); +void gimp_plug_in_progress_pulse (GimpPlugIn *plug_in); +guint32 gimp_plug_in_progress_get_window (GimpPlugIn *plug_in); + +gboolean gimp_plug_in_progress_install (GimpPlugIn *plug_in, + const gchar *progress_callback); +gboolean gimp_plug_in_progress_uninstall (GimpPlugIn *plug_in, + const gchar *progress_callback); +gboolean gimp_plug_in_progress_cancel (GimpPlugIn *plug_in, + const gchar *progress_callback); #endif /* __GIMP_PLUG_IN_PROGRESS_H__ */ diff --git a/app/plug-in/gimppluginprocframe.c b/app/plug-in/gimppluginprocframe.c index c74523f4bf..d134e6f2c9 100644 --- a/app/plug-in/gimppluginprocframe.c +++ b/app/plug-in/gimppluginprocframe.c @@ -77,6 +77,9 @@ gimp_plug_in_proc_frame_init (GimpPlugInProcFrame *proc_frame, proc_frame->progress = progress ? g_object_ref (progress) : NULL; proc_frame->progress_created = FALSE; proc_frame->progress_cancel_id = 0; + + if (progress) + gimp_plug_in_progress_attach (progress); } void