[prev in list] [next in list] [prev in thread] [next in thread]
List: kwrite-devel
Subject: Re: Destroying toolviews in python
From: "Philipp A." <flying-sheep () web ! de>
Date: 2014-02-18 22:28:12
Message-ID: CAN8d9gnjn78=B_ei4Zum-_rCfhDoFGkvs1-fRpLA2-7ubhb4WA () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
2014-02-18 21:39 GMT+01:00 Alex Turbov
i.zaufi@gmail.com<http://mailto:i.zaufi@gmail.com>
:
On Wed, Feb 19, 2014 at 12:07 AM, Philipp A.
flying-sheep@web.de<http://mailto:flying-sheep@web.de>wrote:
2014-02-18 19:15 GMT+01:00 Alex Turbov
i.zaufi@gmail.com<http://mailto:i.zaufi@gmail.com>
:
the problem already solved for color_tools and cmake_utils (at least) —
rebuild kate…
the problem never existed in those. as i said, it has to do with ZMQ, which
is only used in ipython.
wrong!
the root of the problem laid in an object ownership idioms are clashed:
Python w/ GC vs. Qt (w/ QObject parents) vs. C++ (w/ destructors).
I've done a deep investigation about a month ago. that time I've found a
workaround/fix for that:
the plugin w/ a toolview *must* explicitly destroy it on unload. the method
has implemented as a "part" of MainWindow class and available only to
Python code. it helps to break a dependency in Python, then it uses Qt way
to destroy, which is finally calls a C++ destructor (after deleteLater()).
eh, that's basically what i said: the different destruction methods don't
play ball. why is what i said "wrong"?
is there a way to make Tool
the investigation was initiated by Shaheed in a private emails. same
(ownership) problem was discovered for gid plugin…
so, *rebuild Pâtê and dive into to the color_tools/cmake_utils sources*.
OK, so i just deleted the katesipapi.cpp and the .h next to it (or similar).
the changes are pretty trivial now:
diff --git a/addons/kate/pate/src/plugins/python_console_ipython/python_console_ipython.py
b/addons/kate/pate/src/plugins/python_console_ipython/python_console_ipython.py
index 29623c7..07fb275 100644---
a/addons/kate/pate/src/plugins/python_console_ipython/python_console_ipython.py+++
b/addons/kate/pate/src/plugins/python_console_ipython/python_console_ipython.py
@@ -307,9 +307,10 @@ class ConsoleToolView(QObject):
def __del__(self):
"""Plugins that use a toolview need to delete it for
reloading to work."""- if self.toolView:-
self.toolView.deleteLater()- self.toolView = None+
mw = kate.mainInterfaceWindow()+ if mw:+
mw.destroyToolView(self.toolView)+ self.console = None
def eventFilter(self, obj, event):
"""Hide the IPython console tool view on ESCAPE key"""
shall i just commit that?
[Attachment #5 (text/html)]
<div dir="ltr"><div style class="markdown-here-wrapper" \
id="markdown-here-wrapper-28662"><p style="margin:1.2em 0px!important">2014-02-18 \
21:39 GMT+01:00 Alex Turbov <a \
href="http://mailto:i.zaufi@gmail.com">i.zaufi@gmail.com</a>:</p>
<blockquote style="margin:1.2em 0px;border-left:4px solid \
rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none"> <p \
style="margin:1.2em 0px!important">On Wed, Feb 19, 2014 at 12:07 AM, Philipp A. <a \
href="http://mailto:flying-sheep@web.de">flying-sheep@web.de</a> wrote:</p> \
<blockquote style="margin:1.2em 0px;border-left:4px solid \
rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none"> <p \
style="margin:1.2em 0px!important">2014-02-18 19:15 GMT+01:00 Alex Turbov <a \
href="http://mailto:i.zaufi@gmail.com">i.zaufi@gmail.com</a>:</p> <blockquote \
style="margin:1.2em 0px;border-left:4px solid rgb(221,221,221);padding:0px \
1em;color:rgb(119,119,119);quotes:none"> <p style="margin:1.2em 0px!important">the \
problem already solved for color_tools and cmake_utils (at least) — rebuild <code \
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px \
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid \
rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">kate</code>…</p>
</blockquote>
<p style="margin:1.2em 0px!important">the problem never existed in those. as i said, \
it has to do with ZMQ, which is only used in ipython.</p> </blockquote>
<p style="margin:1.2em 0px!important">wrong!<br>the root of the problem laid in an \
object ownership idioms are clashed: Python w/ GC vs. Qt (w/ QObject parents) vs. C++ \
(w/ destructors).<br>I've done a deep investigation about a month ago. that time I've \
found a workaround/fix for that:<br>
the plugin w/ a toolview <strong>must</strong> explicitly destroy it on unload. the \
method has implemented as a "part" of MainWindow class and available only to Python \
code. it helps to break a dependency in Python, then it uses Qt way to destroy, which \
is finally calls a C++ destructor (after deleteLater()).</p>
</blockquote>
<p style="margin:1.2em 0px!important">eh, that's basically what i said: the different \
destruction methods don't play ball. why is what i said "wrong"?</p> <p \
style="margin:1.2em 0px!important">is there a way to make Tool</p> <blockquote \
style="margin:1.2em 0px;border-left:4px solid rgb(221,221,221);padding:0px \
1em;color:rgb(119,119,119);quotes:none"> <p style="margin:1.2em 0px!important">the \
investigation was initiated by Shaheed in a private emails. same (ownership) problem \
was discovered for <code \
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px \
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid \
rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">gid</code> \
plugin…</p>
<p style="margin:1.2em 0px!important">so, <strong>rebuild Pâtê and dive into to the \
color_tools/cmake_utils sources</strong>.</p> </blockquote>
<p style="margin:1.2em 0px!important">OK, so i just deleted the katesipapi.cpp and \
the .h next to it (or similar).</p> <p style="margin:1.2em 0px!important">the changes \
are pretty trivial now:</p> <pre \
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em \
0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px \
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid \
rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px \
solid rgb(204,204,204);padding:0.5em \
0.7em;display:block!important;display:block;padding:0.5em;color:rgb(51,51,51);background:none \
repeat scroll 0% 0% rgb(248,248,255)" class="language-diff">diff --git \
a/addons/kate/pate/src/plugins/python_console_ipython/python_console_ipython.py \
b/addons/kate/pate/src/plugins/python_console_ipython/python_console_ipython.py \
index 29623c7..07fb275 100644
<span class="header">--- \
a/addons/kate/pate/src/plugins/python_console_ipython/python_console_ipython.py</span>
<span class="header">+++ \
b/addons/kate/pate/src/plugins/python_console_ipython/python_console_ipython.py</span>
@@ -307,9 +307,10 @@ class ConsoleToolView(QObject):
def __del__(self):
"""Plugins that use a toolview need to delete it for \
reloading to work.""" <span style="background:none repeat scroll 0% 0% \
rgb(255,221,221)" class="deletion">- if self.toolView:</span> <span \
style="background:none repeat scroll 0% 0% rgb(255,221,221)" class="deletion">- \
self.toolView.deleteLater()</span> <span style="background:none repeat scroll 0% 0% \
rgb(255,221,221)" class="deletion">- self.toolView = None</span> <span \
style="background:none repeat scroll 0% 0% rgb(221,255,221)" class="addition">+ \
mw = kate.mainInterfaceWindow()</span> <span style="background:none repeat scroll 0% \
0% rgb(221,255,221)" class="addition">+ if mw:</span> <span \
style="background:none repeat scroll 0% 0% rgb(221,255,221)" class="addition">+ \
mw.destroyToolView(self.toolView)</span> <span style="background:none repeat scroll \
0% 0% rgb(221,255,221)" class="addition">+ self.console = None</span>
def eventFilter(self, obj, event):
"""Hide the IPython console tool view on ESCAPE \
key""" </code></pre>
<p style="margin:1.2em 0px!important">shall i just commit that?</p>
</div></div>
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic