DrCyanide / cyanic-sd-krita

A Stable Diffusion plugin for Krita, compatible with A1111 and SD.Next
70 stars 4 forks source link

Changing tabs mid-generation breaks UI #18

Closed Miraihi closed 6 months ago

Miraihi commented 11 months ago

When I open the "Simplify UI" menu during the generation, I get spammed to death by the following error. It doesn't go away until I close Krita.

RuntimeError
Python 3.10.7: C:\Program Files (x86)\Steam\steamapps\common\Krita\krita\bin\krita.exe
Fri Oct 27 03:29:17 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\Miraihi\AppData\Roaming\krita\pykrita\cyanic\widgets\generate.py in <lambda>()
   94             self.kc.run_as_thread(lambda: self.threadable_run(data), lambda: self.threadable_return(x, y, w, h))
   95             self.progress_timer = QTimer()
   96             self.progress_timer.timeout.connect(lambda: self.progress_check(x,y,w,h))
   97             # Set the refresh rate
   98             if self.settings_controller.has_key('previews.refresh_seconds'):
self = <cyanic.widgets.generate.GenerateWidget object>
self.progress_timer = <PyQt5.QtCore.QTimer object>
self.progress_timer.timeout = <bound PYQT_SIGNAL timeout of QTimer object>
self.progress_timer.timeout.connect = <built-in method connect of PyQt5.QtCore.pyqtBoundSignal object>
self.progress_check = <bound method GenerateWidget.progress_check of <cyanic.widgets.generate.GenerateWidget object>>
x = 0
y = 0
w = 1125
h = 1500

 C:\Users\Miraihi\AppData\Roaming\krita\pykrita\cyanic\widgets\generate.py in progress_check(self=<cyanic.widgets.generate.GenerateWidget object>, x=0, y=0, w=1125, h=1500)
  125             # Kill the progress check
  126             self.abort = False
  127             self.progress_bar.setValue(1)
  128             self.kc.delete_preview_layer()
  129             self.progress_timer.stop()
self = <cyanic.widgets.generate.GenerateWidget object>
self.progress_bar = <PyQt5.QtWidgets.QProgressBar object>
self.progress_bar.setValue = <built-in method setValue of QProgressBar object>
RuntimeError: wrapped C/C++ object of type QProgressBar has been deleted
    __cause__ = None
    __class__ = <class 'RuntimeError'>
    __context__ = RuntimeError('wrapped C/C++ object of type QProgressBar has been deleted')
    __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 QProgressBar 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\Miraihi\AppData\Roaming\krita\pykrita\cyanic\widgets\generate.py", line 119, in progress_check
    self.progress_bar.setValue(int(results['progress'] * 100))
RuntimeError: wrapped C/C++ object of type QProgressBar has been deleted

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Miraihi\AppData\Roaming\krita\pykrita\cyanic\widgets\generate.py", line 96, in <lambda>
    self.progress_timer.timeout.connect(lambda: self.progress_check(x,y,w,h))
  File "C:\Users\Miraihi\AppData\Roaming\krita\pykrita\cyanic\widgets\generate.py", line 127, in progress_check
    self.progress_bar.setValue(1)
RuntimeError: wrapped C/C++ object of type QProgressBar has been deleted
DrCyanide commented 11 months ago

Did you switch tabs while an image was generating? I think that's the only way this error could pop up.

Miraihi commented 11 months ago

Yes, I've switched from "txt2img" to "Simplify UI".

DrCyanide commented 11 months ago

Don't switch mid-generation for now and you shouldn't encounter the error again.

Right now the tabs aren't saved when you switch between them, they're deleted and replaced. When you switched tabs mid-generation, the progress bar updater couldn't find it's progress bar, and proceeded to crash.

I want to reuse the tabs because that's a better user experience (allows your Extensions to remember what settings they had when switching back and forth between tabs), but the last time I tried that I got a bunch of errors. I'll try circling back to it after I'm done adding features.

DrCyanide commented 6 months ago

Pull the latest version. Switching tabs now shouldn't crash the image generation. It doesn't let you interrupt it or see the progress if you go back.