[gimp] plug-ins: check for run_procedure SUCCESS in openraster
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: check for run_procedure SUCCESS in openraster
- Date: Thu, 28 Jan 2021 00:09:24 +0000 (UTC)
commit d87cd48f0222a300d6e6fd3b4fddcb522a53864e
Author: Jacob Boerema <jgboerema gmail com>
Date: Wed Jan 27 19:00:31 2021 -0500
plug-ins: check for run_procedure SUCCESS in openraster
The Openraster plug-in calls file-png-load and
gimp-file-load-layer but didn't check if the result
was SUCCESS. Even though I haven't seen any
failures let's improve error checking by adding
a check for a correct result.
plug-ins/python/file-openraster.py | 39 ++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)
---
diff --git a/plug-ins/python/file-openraster.py b/plug-ins/python/file-openraster.py
index d9db4fdfd7..d76933c819 100755
--- a/plug-ins/python/file-openraster.py
+++ b/plug-ins/python/file-openraster.py
@@ -164,23 +164,30 @@ def thumbnail_ora(procedure, file, thumb_size, args, data):
with open(tmp, 'wb') as fid:
fid.write(orafile.read('Thumbnails/thumbnail.png'))
- img = Gimp.get_pdb().run_procedure('file-png-load', [
+ result = Gimp.get_pdb().run_procedure('file-png-load', [
GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE),
GObject.Value(GObject.TYPE_STRING, tmp),
])
- img = img.index(1)
- # TODO: scaling
os.remove(tmp)
os.rmdir(tempdir)
- return Gimp.ValueArray.new_from_values([
- GObject.Value(Gimp.PDBStatusType, Gimp.PDBStatusType.SUCCESS),
- GObject.Value(Gimp.Image, img),
- GObject.Value(GObject.TYPE_INT, w),
- GObject.Value(GObject.TYPE_INT, h),
- GObject.Value(Gimp.ImageType, Gimp.ImageType.RGB_IMAGE),
- GObject.Value(GObject.TYPE_INT, 1)
- ])
+ if (result.index(0) == Gimp.PDBStatusType.SUCCESS):
+ img = result.index(1)
+ # TODO: scaling
+
+ return Gimp.ValueArray.new_from_values([
+ GObject.Value(Gimp.PDBStatusType, Gimp.PDBStatusType.SUCCESS),
+ GObject.Value(Gimp.Image, img),
+ GObject.Value(GObject.TYPE_INT, w),
+ GObject.Value(GObject.TYPE_INT, h),
+ GObject.Value(Gimp.ImageType, Gimp.ImageType.RGB_IMAGE),
+ GObject.Value(GObject.TYPE_INT, 1)
+ ])
+ else:
+ return Gimp.ValueArray.new_from_values([
+ GObject.Value(Gimp.PDBStatusType, result.index(0)),
+ GObject.Value(GObject.Error, result.index(1))
+ ])
# We would expect the n_drawables parameter to not be there with introspection but
# currently that isn't working, see issue #5312. Until that is resolved we keep
@@ -406,13 +413,17 @@ def load_ora(procedure, run_mode, file, args, data):
fid.write(data)
# import layer, set attributes and add to image
- gimp_layer = Gimp.get_pdb().run_procedure('gimp-file-load-layer', [
+ result = gimp_layer = Gimp.get_pdb().run_procedure('gimp-file-load-layer', [
GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE),
GObject.Value(Gimp.Image, img),
GObject.Value(Gio.File, Gio.File.new_for_path(tmp)),
])
- gimp_layer = gimp_layer.index(1)
- os.remove(tmp)
+ if (result.index(0) == Gimp.PDBStatusType.SUCCESS):
+ gimp_layer = gimp_layer.index(1)
+ os.remove(tmp)
+ else:
+ print("Error loading layer from openraster image.")
+
gimp_layer.set_name(name)
gimp_layer.set_mode(layer_mode)
gimp_layer.set_offsets(x, y) # move to correct position
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]