JasonS09 / comfy_sd_krita_plugin

Make AI art between canvas and nodes with Krita.
MIT License
148 stars 7 forks source link

Error when generate button is clicked twice or generation is interrupted , and no image is added to canvas #45

Open nabileisa opened 8 months ago

nabileisa commented 8 months ago

Describe the bug this is two bugs not just one but they are related The first : To Reproduce Steps to reproduce the behavior:

  1. open krita and select an area ,
  2. click the start generating button twice
  3. click on interrupt button
  4. change prompt and click generate again and wit till finished
  5. no image is add to canvas despite the generation completing and image added to output folder This is what shows in the live preview docker, but there is no error in comfy console image

EDIT: In addition to what I describe above , If you click the start generating button twice too fast the last generated image would be added to canvas and no new image would be generated and this behavior will continue if if you try to click it again once no new image will be generated and last generated image will be added again until krita is restarted

The second: when trying to exit krita after the first happen , this error shows, and won't go away unless I kill krita process from task manager

RuntimeError
Python 3.10.7: C:\Program Files\Krita (x64)\bin\krita.exe
Mon Dec 25 13:02:30 2023

A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.

 C:\Users\user\AppData\Roaming\krita\pykrita\krita_comfy\pages\workflow.py in <lambda>(s='Ready')
   73         self.workflow.textChanged.connect(
   74             lambda: script.cfg.set("workflow", self.workflow.toPlainText())
   75         )
   76         #self.workflow_to.qcombo.editTextChanged.connect(self.update_prefix)
   77         script.status_changed.connect(lambda s: self.status_bar.set_status(s))
global script = <krita_comfy.script.Script object>
script.status_changed = <bound PYQT_SIGNAL status_changed of Script object>
script.status_changed.connect = <built-in method connect of PyQt5.QtCore.pyqtBoundSignal object>
s = 'Ready'
self = <krita_comfy.pages.workflow.WorkflowPage object>
self.status_bar = <krita_comfy.widgets.status_bar.StatusBar object>
self.status_bar.set_status = <bound method StatusBar.set_status of <krita_comfy.widgets.status_bar.StatusBar object>>

 C:\Users\user\AppData\Roaming\krita\pykrita\krita_comfy\widgets\status_bar.py in set_status(self=<krita_comfy.widgets.status_bar.StatusBar object>, s='Ready')
   16 
   17     def set_status(self, s):
   18         if s == STATE_READY and STATE_URLERROR not in self.text():
   19             return
   20         if (s == STATE_LOADING or s == STATE_DONE) and STATE_INTERRUPT == self.text():
s = 'Ready'
global STATE_READY = 'Ready'
global STATE_URLERROR = 'Network error'
self = <krita_comfy.widgets.status_bar.StatusBar object>
self.text = <built-in method text of StatusBar object>
RuntimeError: wrapped C/C++ object of type StatusBar has been deleted
    __cause__ = None
    __class__ = <class 'RuntimeError'>
    __context__ = None
    __delattr__ = <method-wrapper '__delattr__' of RuntimeError object>
    __dict__ = {}
    __dir__ = <built-in method __dir__ of RuntimeError object>
    __doc__ = 'Unspecified run-time error.'
    __eq__ = <method-wrapper '__eq__' of RuntimeError object>
    __format__ = <built-in method __format__ of RuntimeError object>
    __ge__ = <method-wrapper '__ge__' of RuntimeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of RuntimeError object>
    __gt__ = <method-wrapper '__gt__' of RuntimeError object>
    __hash__ = <method-wrapper '__hash__' of RuntimeError object>
    __init__ = <method-wrapper '__init__' of RuntimeError object>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of RuntimeError object>
    __lt__ = <method-wrapper '__lt__' of RuntimeError object>
    __ne__ = <method-wrapper '__ne__' of RuntimeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of RuntimeError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of RuntimeError object>
    __repr__ = <method-wrapper '__repr__' of RuntimeError object>
    __setattr__ = <method-wrapper '__setattr__' of RuntimeError object>
    __setstate__ = <built-in method __setstate__ of RuntimeError object>
    __sizeof__ = <built-in method __sizeof__ of RuntimeError object>
    __str__ = <method-wrapper '__str__' of RuntimeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = False
    __traceback__ = <traceback object>
    args = ('wrapped C/C++ object of type StatusBar has been deleted',)
    with_traceback = <built-in method with_traceback of RuntimeError object>

The above is a description of an error in a Python program.  Here is
the original traceback:

Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\krita\pykrita\krita_comfy\pages\workflow.py", line 77, in <lambda>
    script.status_changed.connect(lambda s: self.status_bar.set_status(s))
  File "C:\Users\user\AppData\Roaming\krita\pykrita\krita_comfy\widgets\status_bar.py", line 18, in set_status
    if s == STATE_READY and STATE_URLERROR not in self.text():
RuntimeError: wrapped C/C++ object of type StatusBar has been deleted

To Reproduce Steps to reproduce the behavior:

  1. open krita and select an area ,
  2. click the start generating button twice
  3. wait till it finish
  4. only first generated image is added to canvas
  5. attempt to exit application

Screenshots If applicable, add screenshots to help explain your problem. image

Desktop (please complete the following information):

Additional context