Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_gimp_procedure_run_array: no return values, shouldn't happen
#1
Question 
I recently installed Gimp 3.0.0-RC1 using the windows installer (on Win 11 - 64-Bit).

I am new to plug-in development, having only written one plug-in for Gimp 2.10.38 just last week.  The 2.10 plug in works as I expect it to.  In learning plug-in development, I discovered 3.0.0-RC1 and decided to install it and convert my plug-in to work with 3.0.  To start, I attempted to create a simple, "Hello, World!" plug-in.  Currently I have: 

Code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#   GIMP - The GNU Image Manipulation Program
#   Copyright (C) 1995 Spencer Kimball and Peter Mattis
#
#   gimp-tutorial-plug-in.py
#   sample plug-in to illustrate the Python plug-in writing tutorial
#   Copyright (C) 2023 Jacob Boerema
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <https://www.gnu.org/licenses/>.

import sys

import gi
gi.require_version('Gimp','3.0')
from gi.repository import Gimp
gi.require_version('GimpUi','3.0')
from gi.repository import GimpUi
from gi.repository import GLib

class AnimateDrawableOffsets(Gimp.PlugIn):
   def __init__(self):
       super().__init__()
       self.test_cfg = None
       self.log = None
       
   def do_query_procedures(self):
       return [ 'animate-drawable-offsets' ]

   def do_set_i18n (self, name):
       return (False, None, None)

   def do_create_procedure(self,name):
       procedure = Gimp.ImageProcedure.new(self, name, Gimp.PDBProcType.PLUGIN,self.run,None)
       procedure.set_image_types("*")
       procedure.set_sensitivity_mask(Gimp.ProcedureSensitivityMask.DRAWABLES | Gimp.ProcedureSensitivityMask.DRAWABLE)
       procedure.set_menu_label("Animate Drawable Offsets...")
       procedure.add_menu_path('<Image>/Filters/Animation/')
       procedure.set_documentation("Animate Drawable Offsets","Animates offsets of active drawable in new image according to user defined settings.",name)
       procedure.set_attribution("Jamie Miller","Jamie Miller","2024")

       return procedure

   def run(self, procedure, run_mode, image, n_drawables, drawables, config, run_data):
       # function code goes here...
       Gimp.message("Hello world!")

       return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, GLib.Error())

Gimp.main(AnimateDrawableOffsets.__gtype__, sys.argv)

I can select the plug in from the menu just fine, but I am not seeing output in the Error Console (as I think that is where Gimp.message() outputs the message) and I am seeing the following error in the terminal window:

Code:
(animate-drawable-offsets.py:35024): LibGimp-WARNING **: 20:54:36.115: _gimp_procedure_run_array: no return values, shouldn't happen
C:\Users\dontl\AppData\Roaming\GIMP\3.0\plug-ins\animate-drawable-offsets\animate-drawable-offsets.py:62: Warning: g_error_new: assertion 'domain != 0' failed
 Gimp.main(AnimateDrawableOffsets.__gtype__, sys.argv)

I have tried google the error messages but only found one thread regarding foggify that didn't seem to provide a relevant fix.  I also read the thread regarding the "group-selected-by" plug-in and followed some suggestions in that thread to update my code but I am still seeing the error....

Any help to resolve this would be great....

(11-21-2024, 03:17 AM)JustJamie Wrote: UPDATED:
Code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#   GIMP - The GNU Image Manipulation Program
#   Copyright (C) 1995 Spencer Kimball and Peter Mattis
#
#   gimp-tutorial-plug-in.py
#   sample plug-in to illustrate the Python plug-in writing tutorial
#   Copyright (C) 2023 Jacob Boerema
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <https://www.gnu.org/licenses/>.

import sys

import gi
gi.require_version('Gimp','3.0')
from gi.repository import Gimp
gi.require_version('GimpUi','3.0')
from gi.repository import GimpUi
from gi.repository import GLib

class AnimateDrawableOffsets(Gimp.PlugIn):
   def __init__(self):
       super().__init__()
       self.test_cfg = None
       self.log = None
       
   def do_query_procedures(self):
       return [ 'animate-drawable-offsets' ]

   def do_set_i18n (self, name):
       return (False, None, None)

   def do_create_procedure(self,name):
       procedure = Gimp.ImageProcedure.new(self, name, Gimp.PDBProcType.PLUGIN,self.run,None)
       procedure.set_image_types("*")
       procedure.set_sensitivity_mask(Gimp.ProcedureSensitivityMask.DRAWABLES | Gimp.ProcedureSensitivityMask.DRAWABLE)
       procedure.set_menu_label("Animate Drawable Offsets...")
       procedure.add_menu_path('<Image>/Filters/Animation/')
       procedure.set_documentation("Animate Drawable Offsets","Animates offsets of active drawable in new image according to user defined settings.",name)
       procedure.set_attribution("Jamie Miller","Jamie Miller","2024")

       return procedure
##UPDATED function definition to remove 'run_data' parameter
   def run(self, procedure, run_mode, image, n_drawables, drawables, config):
       # function code goes here...
       Gimp.message("Hello world!")

       return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, GLib.Error())

Gimp.main(AnimateDrawableOffsets.__gtype__, sys.argv)


OK.....so, after re-reading the error message, I noticed it also included the line, " missing 1 required positional argument: 'run_data'"...removing this parameter from the definition for the run function allows the plug-in to operate and I can now see the "Hello, World!" message in the error console.....

I do not know what this parameter is for, or how removing it will affect the plug-in development.  For now, I will keep researching what this parameter is used for and how it becomes populated with run_data.
Reply
#2
(11-21-2024, 03:17 AM)JustJamie Wrote: I recently installed Gimp 3.0.0-RC1 using the windows installer (on Win 11 - 64-Bit).

I am new to plug-in development, having only written one plug-in for Gimp 2.10.38 just last week.  The 2.10 plug in works as I expect it to.  In learning plug-in development, I discovered 3.0.0-RC1 and decided to install it and convert my plug-in to work with 3.0.  To start, I attempted to create a simple, "Hello, World!" plug-in.  Currently I have: 

Code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#   GIMP - The GNU Image Manipulation Program
#   Copyright (C) 1995 Spencer Kimball and Peter Mattis
#
#   gimp-tutorial-plug-in.py
#   sample plug-in to illustrate the Python plug-in writing tutorial
#   Copyright (C) 2023 Jacob Boerema
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <https://www.gnu.org/licenses/>.

import sys

import gi
gi.require_version('Gimp','3.0')
from gi.repository import Gimp
gi.require_version('GimpUi','3.0')
from gi.repository import GimpUi
from gi.repository import GLib

class AnimateDrawableOffsets(Gimp.PlugIn):
   def __init__(self):
       super().__init__()
       self.test_cfg = None
       self.log = None
       
   def do_query_procedures(self):
       return [ 'animate-drawable-offsets' ]

   def do_set_i18n (self, name):
       return (False, None, None)

   def do_create_procedure(self,name):
       procedure = Gimp.ImageProcedure.new(self, name, Gimp.PDBProcType.PLUGIN,self.run,None)
       procedure.set_image_types("*")
       procedure.set_sensitivity_mask(Gimp.ProcedureSensitivityMask.DRAWABLES | Gimp.ProcedureSensitivityMask.DRAWABLE)
       procedure.set_menu_label("Animate Drawable Offsets...")
       procedure.add_menu_path('<Image>/Filters/Animation/')
       procedure.set_documentation("Animate Drawable Offsets","Animates offsets of active drawable in new image according to user defined settings.",name)
       procedure.set_attribution("Jamie Miller","Jamie Miller","2024")

       return procedure

   def run(self, procedure, run_mode, image, n_drawables, drawables, config, run_data):
       # function code goes here...
       Gimp.message("Hello world!")

       return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, GLib.Error())

Gimp.main(AnimateDrawableOffsets.__gtype__, sys.argv)

I can select the plug in from the menu just fine, but I am not seeing output in the Error Console (as I think that is where Gimp.message() outputs the message) and I am seeing the following error in the terminal window:

Code:
(animate-drawable-offsets.py:35024): LibGimp-WARNING **: 20:54:36.115: _gimp_procedure_run_array: no return values, shouldn't happen
C:\Users\dontl\AppData\Roaming\GIMP\3.0\plug-ins\animate-drawable-offsets\animate-drawable-offsets.py:62: Warning: g_error_new: assertion 'domain != 0' failed
 Gimp.main(AnimateDrawableOffsets.__gtype__, sys.argv)

I have tried google the error messages but only found one thread regarding foggify that didn't seem to provide a relevant fix.  I also read the thread regarding the "group-selected-by" plug-in and followed some suggestions in that thread to update my code but I am still seeing the error....

Any help to resolve this would be great....

(11-21-2024, 03:17 AM)JustJamie Wrote: UPDATED:
Code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#   GIMP - The GNU Image Manipulation Program
#   Copyright (C) 1995 Spencer Kimball and Peter Mattis
#
#   gimp-tutorial-plug-in.py
#   sample plug-in to illustrate the Python plug-in writing tutorial
#   Copyright (C) 2023 Jacob Boerema
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <https://www.gnu.org/licenses/>.

import sys

import gi
gi.require_version('Gimp','3.0')
from gi.repository import Gimp
gi.require_version('GimpUi','3.0')
from gi.repository import GimpUi
from gi.repository import GLib

class AnimateDrawableOffsets(Gimp.PlugIn):
   def __init__(self):
       super().__init__()
       self.test_cfg = None
       self.log = None
       
   def do_query_procedures(self):
       return [ 'animate-drawable-offsets' ]

   def do_set_i18n (self, name):
       return (False, None, None)

   def do_create_procedure(self,name):
       procedure = Gimp.ImageProcedure.new(self, name, Gimp.PDBProcType.PLUGIN,self.run,None)
       procedure.set_image_types("*")
       procedure.set_sensitivity_mask(Gimp.ProcedureSensitivityMask.DRAWABLES | Gimp.ProcedureSensitivityMask.DRAWABLE)
       procedure.set_menu_label("Animate Drawable Offsets...")
       procedure.add_menu_path('<Image>/Filters/Animation/')
       procedure.set_documentation("Animate Drawable Offsets","Animates offsets of active drawable in new image according to user defined settings.",name)
       procedure.set_attribution("Jamie Miller","Jamie Miller","2024")

       return procedure
##UPDATED function definition to remove 'run_data' parameter
   def run(self, procedure, run_mode, image, n_drawables, drawables, config):
       # function code goes here...
       Gimp.message("Hello world!")

       return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, GLib.Error())

Gimp.main(AnimateDrawableOffsets.__gtype__, sys.argv)


OK.....so, after re-reading the error message, I noticed it also included the line, " missing 1 required positional argument: 'run_data'"...removing this parameter from the definition for the run function allows the plug-in to operate and I can now see the "Hello, World!" message in the error console.....

I do not know what this parameter is for, or how removing it will affect the plug-in development.  For now, I will keep researching what this parameter is used for and how it becomes populated with run_data.

run_data is technically a pointer to anything that you want your procedure to access. This is passed to the procedure code as the last "data" parameter. And bizarrely if you omit it when creating the procedure, it is not used in the call to your procedure.

Otherwise, wink, wink, nudge nudge.
Reply
#3
run_data is technically a pointer to anything that you want your procedure to access. This is passed to the procedure code as the last "data" parameter. And bizarrely if you omit it when creating the procedure, it is not used in the call to your procedure.

Otherwise, wink, wink, nudge nudge.



Ofnuts....thank you so much for your quick reply!

Ok...

I believe I would do this in the do_create_procedure function with the following line of code:

procedure = Gimp.ImageProcedure.new(self, name, Gimp.PDBProcType.PLUGIN,self.run,None)

The last argument (None) is the 'run-data' of type gpointer that gets passed to the run function.  I haven't found much information about the gpointer type in the Gimp or GimpUi documentation ...
Reply
#4
(11-21-2024, 12:47 PM)JustJamie Wrote: Ok...

I believe I would do this in the do_create_procedure function with the following line of code:

procedure = Gimp.ImageProcedure.new(self, name, Gimp.PDBProcType.PLUGIN,self.run,None)

The last argument (None) is the 'run-data' of type gpointer that gets passed to the run function.  I haven't found much information about the gpointer type in the Gimp or GimpUi documentation ...

Yes. GPointer is a C thing, it is a pointer to anything. I don't see much use for this in the average Python plugin.
Reply


Forum Jump: