From 2dcc8eea93c5c254ceedc19f55267d72f457135d Mon Sep 17 00:00:00 2001 From: Jehan Date: Thu, 26 Oct 2023 22:07:32 +0200 Subject: [PATCH] app, libgimp, pdb: remove the internal PDB function _gimp_pdb_get_data_size(). We exchange GBytes structs which know their own data size already and is much safer. --- app/pdb/internal-procs.c | 2 +- app/pdb/pdb-cmds.c | 71 ---------------------------------------- libgimp/gimppdb_pdb.c | 36 -------------------- libgimp/gimppdb_pdb.h | 1 - pdb/groups/pdb.pdb | 45 ------------------------- 5 files changed, 1 insertion(+), 154 deletions(-) diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c index a069f7d29f..b2bae42b56 100644 --- a/app/pdb/internal-procs.c +++ b/app/pdb/internal-procs.c @@ -30,7 +30,7 @@ #include "internal-procs.h" -/* 780 procedures registered total */ +/* 779 procedures registered total */ void internal_procs_init (GimpPDB *pdb) diff --git a/app/pdb/pdb-cmds.c b/app/pdb/pdb-cmds.c index 5f2e5ba48d..da136515cc 100644 --- a/app/pdb/pdb-cmds.c +++ b/app/pdb/pdb-cmds.c @@ -1163,47 +1163,6 @@ pdb_get_data_invoker (GimpProcedure *procedure, return return_vals; } -static GimpValueArray * -pdb_get_data_size_invoker (GimpProcedure *procedure, - Gimp *gimp, - GimpContext *context, - GimpProgress *progress, - const GimpValueArray *args, - GError **error) -{ - gboolean success = TRUE; - GimpValueArray *return_vals; - const gchar *identifier; - gint bytes = 0; - - identifier = g_value_get_string (gimp_value_array_index (args, 0)); - - if (success) - { - if (gimp_is_canonical_identifier (identifier)) - { - if (! gimp_plug_in_manager_get_data (gimp->plug_in_manager, - identifier, &bytes)) - success = FALSE; - } - else - { - g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, - _("Data label '%s' is not a canonical identifier"), - identifier); - success = FALSE; - } - } - - return_vals = gimp_procedure_get_return_values (procedure, success, - error ? *error : NULL); - - if (success) - g_value_set_int (gimp_value_array_index (return_vals, 1), bytes); - - return return_vals; -} - static GimpValueArray * pdb_set_data_invoker (GimpProcedure *procedure, Gimp *gimp, @@ -2226,36 +2185,6 @@ register_pdb_procs (GimpPDB *pdb) gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); - /* - * gimp-pdb-get-data-size - */ - procedure = gimp_procedure_new (pdb_get_data_size_invoker); - gimp_object_set_static_name (GIMP_OBJECT (procedure), - "gimp-pdb-get-data-size"); - gimp_procedure_set_static_help (procedure, - "Returns size of data associated with the specified identifier.", - "This procedure returns the size of any data which may have been associated with the specified identifier. If no data has been associated with the identifier, an error is returned.", - NULL); - gimp_procedure_set_static_attribution (procedure, - "Nick Lamb", - "Nick Lamb", - "1998"); - gimp_procedure_add_argument (procedure, - gimp_param_spec_string ("identifier", - "identifier", - "The identifier associated with data", - FALSE, FALSE, TRUE, - NULL, - GIMP_PARAM_READWRITE)); - gimp_procedure_add_return_value (procedure, - g_param_spec_int ("bytes", - "bytes", - "The number of bytes in the data", - 1, G_MAXINT32, 1, - GIMP_PARAM_READWRITE)); - gimp_pdb_register_procedure (pdb, procedure); - g_object_unref (procedure); - /* * gimp-pdb-set-data */ diff --git a/libgimp/gimppdb_pdb.c b/libgimp/gimppdb_pdb.c index 9c11cf7032..5cca6c46c3 100644 --- a/libgimp/gimppdb_pdb.c +++ b/libgimp/gimppdb_pdb.c @@ -1215,42 +1215,6 @@ _gimp_pdb_get_data (const gchar *identifier, return success; } -/** - * _gimp_pdb_get_data_size: - * @identifier: The identifier associated with data. - * - * Returns size of data associated with the specified identifier. - * - * This procedure returns the size of any data which may have been - * associated with the specified identifier. If no data has been - * associated with the identifier, an error is returned. - * - * Returns: The number of bytes in the data. - **/ -gint -_gimp_pdb_get_data_size (const gchar *identifier) -{ - GimpValueArray *args; - GimpValueArray *return_vals; - gint bytes = 0; - - args = gimp_value_array_new_from_types (NULL, - G_TYPE_STRING, identifier, - G_TYPE_NONE); - - return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (), - "gimp-pdb-get-data-size", - args); - gimp_value_array_unref (args); - - if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) - bytes = GIMP_VALUES_GET_INT (return_vals, 1); - - gimp_value_array_unref (return_vals); - - return bytes; -} - /** * _gimp_pdb_set_data: * @identifier: The identifier associated with data. diff --git a/libgimp/gimppdb_pdb.h b/libgimp/gimppdb_pdb.h index 4497a54a89..c8e260ac2f 100644 --- a/libgimp/gimppdb_pdb.h +++ b/libgimp/gimppdb_pdb.h @@ -100,7 +100,6 @@ G_GNUC_INTERNAL gboolean _gimp_pdb_set_batch_interpreter (const gcha const gchar *interpreter_name); G_GNUC_INTERNAL gboolean _gimp_pdb_get_data (const gchar *identifier, GBytes **data); -G_GNUC_INTERNAL gint _gimp_pdb_get_data_size (const gchar *identifier); G_GNUC_INTERNAL gboolean _gimp_pdb_set_data (const gchar *identifier, GBytes *data); diff --git a/pdb/groups/pdb.pdb b/pdb/groups/pdb.pdb index 1511b66d16..ffd6a021f1 100644 --- a/pdb/groups/pdb.pdb +++ b/pdb/groups/pdb.pdb @@ -1246,50 +1246,6 @@ CODE ); } -sub pdb_get_data_size { - $blurb = 'Returns size of data associated with the specified identifier.'; - - $help = <<'HELP'; -This procedure returns the size of any data which may have been associated with -the specified identifier. If no data has been associated with the identifier, -an error is returned. -HELP - - &nick_pdb_misc('1998'); - - $lib_private = 1; - - @inargs = ( - { name => 'identifier', type => 'string', non_empty => 1, - desc => 'The identifier associated with data' } - ); - - @outargs = ( - { name => 'bytes', type => '1 <= int32', - desc => 'The number of bytes in the data' } - ); - - %invoke = ( - code => <<'CODE' -{ - if (gimp_is_canonical_identifier (identifier)) - { - if (! gimp_plug_in_manager_get_data (gimp->plug_in_manager, - identifier, &bytes)) - success = FALSE; - } - else - { - g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, - _("Data label '%s' is not a canonical identifier"), - identifier); - success = FALSE; - } -} -CODE - ); -} - sub pdb_set_data { $blurb = 'Associates the specified identifier with the supplied data.'; @@ -1398,7 +1354,6 @@ CODE pdb_set_file_proc_thumbnail_loader pdb_set_batch_interpreter pdb_get_data - pdb_get_data_size pdb_set_data); %exports = (app => [@procs], lib => [@procs]);