Refactor PyKrita plugin
ClosedPublic

Authored by jounip on Dec 7 2017, 10:04 AM.

Details

Reviewers
rempt
Group Reviewers
Krita
Maniphest Tasks
T1625: Python Scripting
Summary

The plugin's code was refactored closer to Krita's usual coding style.

Also fixes saving/loading Python plugin enable flags.

Diff Detail

Repository
R37 Krita
Lint
Lint Skipped
Unit
Unit Tests Skipped
jounip created this revision.Dec 7 2017, 10:04 AM
Restricted Application added a subscriber: woltherav. · View Herald TranscriptDec 7 2017, 10:04 AM
jounip requested review of this revision.Dec 7 2017, 10:04 AM
rempt added a comment.Dec 7 2017, 10:49 AM

Maybe the plugins should be enabled instead of disabled by default? Or we could add a default enabled/disabled setting in the .desktop files' metadata.

Also, after enabling some plugins, I get a crash on shutdown, and on restarting the last plugin I enabled isn't loaded:

Exception ignored in: <module 'threading' from '/usr/lib64/python3.4/threading.py'>
Traceback (most recent call last):

File "/usr/lib64/python3.4/threading.py", line 1283, in _shutdown
  t = _pickSomeNonDaemonThread()
File "/usr/lib64/python3.4/threading.py", line 1290, in _pickSomeNonDaemonThread
  for t in enumerate():
File "/usr/lib64/python3.4/threading.py", line 1260, in enumerate
  return list(_active.values()) + list(_limbo.values())

KeyError: 'tenscripts'

Then on starting and closing Krita again, I get an assert:

Thread 1 (Thread 0x7f890a982940 (LWP 25921)):
[KCrash Handler]
#6 0x00007f89000b7260 in QObject::thread() const () at /usr/lib64/libQt5Core.so.5
#7 0x00007f89067ac716 in kis_assert_common(char const*, char const*, int, bool, bool) (assertion=assertion@entry=0x7f88a84a9245 "!plugin.m_loaded", file=file@entry=0x7f88a84a9528 "/home/boud/dev/jouni/plugins/extensions/pykrita/plugin/PythonPluginManager.cpp", line=line@entry=374, throwException=throwException@entry=false, isIgnorable=isIgnorable@entry=true) at /home/boud/dev/jouni/libs/global/kis_assert.cpp:66
#8 0x00007f89067acbfd in kis_safe_assert_recoverable(char const*, char const*, int) (assertion=assertion@entry=0x7f88a84a9245 "!plugin.m_loaded", file=file@entry=0x7f88a84a9528 "/home/boud/dev/jouni/plugins/extensions/pykrita/plugin/PythonPluginManager.cpp", line=line@entry=374) at /home/boud/dev/jouni/libs/global/kis_assert.cpp:108
#9 0x00007f88a849ed08 in PythonPluginManager::unloadModule(PythonPlugin&) (this=this@entry=0xa41e760, plugin=...) at /home/boud/dev/jouni/plugins/extensions/pykrita/plugin/PythonPluginManager.cpp:374
#10 0x00007f88a84a2766 in PythonPluginManager::unloadAllModules() (this=this@entry=0xa41e760) at /home/boud/dev/jouni/plugins/extensions/pykrita/plugin/PythonPluginManager.cpp:110
#11 0x00007f88a84a2a84 in PythonPluginManager::~PythonPluginManager() (this=0xa41e760, in_chrg=<optimized out>) at /home/boud/dev/jouni/plugins/extensions/pykrita/plugin/PythonPluginManager.cpp:83
#12 0x00007f88a84a2b09 in PythonPluginManager::~PythonPluginManager() (this=0xa41e760,
in_chrg=<optimized out>) at /home/boud/dev/jouni/plugins/extensions/pykrita/plugin/PythonPluginManager.cpp:87
#13 0x00007f88ff21c139 in run_exit_handlers () at /lib64/libc.so.6
#14 0x00007f88ff21c185 in () at /lib64/libc.so.6
#15 0x00007f88ff2056ec in
libc_start_main () at /lib64/libc.so.6
#16 0x00000000004065f9 in _start () at ../sysdeps/x86_64/start.S:118

jounip updated this revision to Diff 23684.Dec 9 2017, 1:34 PM

Fix bugs introduced during the refactoring, particularly crashes on shutdown.

Also, enable plugins by default.

rempt accepted this revision.Dec 12 2017, 7:57 AM

Looks fine now!

This revision is now accepted and ready to land.Dec 12 2017, 7:57 AM
rempt added a comment.Dec 29 2017, 5:15 PM

Jouni! This needs to be merged to master! Before the 31st!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

rempt closed this revision.Dec 29 2017, 6:29 PM

Pushed

Weird, on master I still get the crash on shutdown

Weird, on master I still get the crash on shutdown

Oops! Looks like I accidentally merged the wrong version. It should be fixed now.