[gimp] libgimp: add a "status" parameter to gimp_procedure_config_end_run()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: add a "status" parameter to gimp_procedure_config_end_run()
- Date: Wed, 25 Sep 2019 10:10:58 +0000 (UTC)
commit 58bf1d431d68d007866ed88f6e6adba769b1b5df
Author: Michael Natterer <mitch gimp org>
Date: Wed Sep 25 12:09:03 2019 +0200
libgimp: add a "status" parameter to gimp_procedure_config_end_run()
and require it to be always called paired with begin_run(), which is
more straightforward and makes the resulting code more future-proof.
libgimp/gimpprocedureconfig.c | 12 +++++++-----
libgimp/gimpprocedureconfig.h | 3 ++-
plug-ins/common/despeckle.c | 2 +-
plug-ins/common/file-gbr.c | 13 +++----------
plug-ins/common/file-heif.c | 3 +--
plug-ins/common/file-pat.c | 7 ++-----
plug-ins/common/file-png.c | 3 +--
plug-ins/file-sgi/sgi.c | 9 +++------
8 files changed, 20 insertions(+), 32 deletions(-)
---
diff --git a/libgimp/gimpprocedureconfig.c b/libgimp/gimpprocedureconfig.c
index ea6de49ba9..0c2f91737b 100644
--- a/libgimp/gimpprocedureconfig.c
+++ b/libgimp/gimpprocedureconfig.c
@@ -380,11 +380,11 @@ gimp_procedure_config_begin_run (GimpProcedureConfig *config,
* @config: a #GimpProcedureConfig
* @image: a #GimpImage or %NULL
* @run_mode: the #GimpRunMode passed to a #GimpProcedure's run()
+ * @status: the return status of the #GimpProcedure's run()
*
* This function is the counterpart of
- * gimp_procedure_conig_begin_run() and should be used upon successful
- * completion of a procedure's run(), before returning
- * %GIMP_PDB_SUCCESS return values.
+ * gimp_procedure_conig_begin_run() and must always be called in pairs
+ * in a procedure's run(), before returning return values.
*
* If @run_mode is %GIMP_RUN_INTERACTIVE, @config is saved as last
* used values to be used when the procedure runs again. Additionally,
@@ -403,7 +403,8 @@ gimp_procedure_config_begin_run (GimpProcedureConfig *config,
void
gimp_procedure_config_end_run (GimpProcedureConfig *config,
GimpImage *image,
- GimpRunMode run_mode)
+ GimpRunMode run_mode,
+ GimpPDBStatusType status)
{
g_return_if_fail (GIMP_IS_PROCEDURE_CONFIG (config));
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
@@ -411,7 +412,8 @@ gimp_procedure_config_end_run (GimpProcedureConfig *config,
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
- if (run_mode == GIMP_RUN_INTERACTIVE)
+ if (status == GIMP_PDB_SUCCESS &&
+ run_mode == GIMP_RUN_INTERACTIVE)
{
GError *error = NULL;
diff --git a/libgimp/gimpprocedureconfig.h b/libgimp/gimpprocedureconfig.h
index ba780e63e9..238eba6dcb 100644
--- a/libgimp/gimpprocedureconfig.h
+++ b/libgimp/gimpprocedureconfig.h
@@ -81,7 +81,8 @@ void gimp_procedure_config_begin_run (GimpProcedureConfig *config,
const GimpValueArray *args);
void gimp_procedure_config_end_run (GimpProcedureConfig *config,
GimpImage *image,
- GimpRunMode run_mode);
+ GimpRunMode run_mode,
+ GimpPDBStatusType status);
G_END_DECLS
diff --git a/plug-ins/common/despeckle.c b/plug-ins/common/despeckle.c
index da4fee41a4..2611e9e601 100644
--- a/plug-ins/common/despeckle.c
+++ b/plug-ins/common/despeckle.c
@@ -252,7 +252,7 @@ despeckle_run (GimpProcedure *procedure,
despeckle (drawable, G_OBJECT (config));
- gimp_procedure_config_end_run (config, NULL, run_mode);
+ gimp_procedure_config_end_run (config, NULL, run_mode, GIMP_PDB_SUCCESS);
g_object_unref (config);
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
diff --git a/plug-ins/common/file-gbr.c b/plug-ins/common/file-gbr.c
index fe133d9b31..fcbbacd876 100644
--- a/plug-ins/common/file-gbr.c
+++ b/plug-ins/common/file-gbr.c
@@ -226,10 +226,7 @@ gbr_save (GimpProcedure *procedure,
if (run_mode == GIMP_RUN_INTERACTIVE)
{
if (! save_dialog (procedure, G_OBJECT (config)))
- {
- status = GIMP_PDB_CANCEL;
- goto out;
- }
+ status = GIMP_PDB_CANCEL;
}
if (status == GIMP_PDB_SUCCESS)
@@ -255,11 +252,7 @@ gbr_save (GimpProcedure *procedure,
g_free (description);
- if (GIMP_VALUES_GET_ENUM (save_retvals, 0) == GIMP_PDB_SUCCESS)
- {
- gimp_procedure_config_end_run (config, orig_image, run_mode);
- }
- else
+ if (GIMP_VALUES_GET_ENUM (save_retvals, 0) != GIMP_PDB_SUCCESS)
{
g_set_error (&error, 0, 0,
"Running procedure 'file-gbr-save-internal' "
@@ -272,7 +265,7 @@ gbr_save (GimpProcedure *procedure,
gimp_value_array_unref (save_retvals);
}
- out:
+ gimp_procedure_config_end_run (config, orig_image, run_mode, status);
g_object_unref (config);
if (export == GIMP_EXPORT_EXPORT)
diff --git a/plug-ins/common/file-heif.c b/plug-ins/common/file-heif.c
index b644c5a07c..cbda8200e7 100644
--- a/plug-ins/common/file-heif.c
+++ b/plug-ins/common/file-heif.c
@@ -310,8 +310,6 @@ heif_save (GimpProcedure *procedure,
file, NULL);
g_object_unref (metadata);
}
-
- gimp_procedure_config_end_run (config, orig_image, run_mode);
}
else
{
@@ -319,6 +317,7 @@ heif_save (GimpProcedure *procedure,
}
}
+ gimp_procedure_config_end_run (config, orig_image, run_mode, status);
g_object_unref (config);
if (export == GIMP_EXPORT_EXPORT)
diff --git a/plug-ins/common/file-pat.c b/plug-ins/common/file-pat.c
index d6199af6e7..d04a3e86a3 100644
--- a/plug-ins/common/file-pat.c
+++ b/plug-ins/common/file-pat.c
@@ -225,11 +225,7 @@ pat_save (GimpProcedure *procedure,
G_TYPE_STRING, description,
G_TYPE_NONE);
- if (GIMP_VALUES_GET_ENUM (save_retvals, 0) == GIMP_PDB_SUCCESS)
- {
- gimp_procedure_config_end_run (config, orig_image, run_mode);
- }
- else
+ if (GIMP_VALUES_GET_ENUM (save_retvals, 0) != GIMP_PDB_SUCCESS)
{
g_set_error (&error, 0, 0,
"Running procedure 'file-pat-save-internal' "
@@ -242,6 +238,7 @@ pat_save (GimpProcedure *procedure,
gimp_value_array_unref (save_retvals);
}
+ gimp_procedure_config_end_run (config, orig_image, run_mode, status);
g_object_unref (config);
if (export == GIMP_EXPORT_EXPORT)
diff --git a/plug-ins/common/file-png.c b/plug-ins/common/file-png.c
index 160a52a027..56356633de 100644
--- a/plug-ins/common/file-png.c
+++ b/plug-ins/common/file-png.c
@@ -543,8 +543,6 @@ png_save (GimpProcedure *procedure,
g_object_unref (metadata);
}
-
- gimp_procedure_config_end_run (config, orig_image, run_mode);
}
else
{
@@ -552,6 +550,7 @@ png_save (GimpProcedure *procedure,
}
}
+ gimp_procedure_config_end_run (config, orig_image, run_mode, status);
g_object_unref (config);
if (export == GIMP_EXPORT_EXPORT)
diff --git a/plug-ins/file-sgi/sgi.c b/plug-ins/file-sgi/sgi.c
index 2f472754a8..926dce5ad1 100644
--- a/plug-ins/file-sgi/sgi.c
+++ b/plug-ins/file-sgi/sgi.c
@@ -274,17 +274,14 @@ sgi_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS)
{
- if (save_image (file, image, drawable, G_OBJECT (config),
- &error))
- {
- gimp_procedure_config_end_run (config, orig_image, run_mode);
- }
- else
+ if (! save_image (file, image, drawable, G_OBJECT (config),
+ &error))
{
status = GIMP_PDB_EXECUTION_ERROR;
}
}
+ gimp_procedure_config_end_run (config, orig_image, run_mode, status);
g_object_unref (config);
if (export == GIMP_EXPORT_EXPORT)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]