[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: Destroying toolviews in python
From:       Alex Turbov <i.zaufi () gmail ! com>
Date:       2014-02-18 18:15:01
Message-ID: CANktQtvoLhEJ63LJzgtg8Or4VXC=_Y3e3pdkmn1-_pyqPHn+ag () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


the problem already solved for color_tools and cmake_utils (at least) --
rebuild `kate`...



On Tue, Feb 18, 2014 at 7:55 PM, Philipp A. <flying-sheep@web.de> wrote:

> Hi, when unloading the ipython console (in exit or when unchecking it),
> kate segfaults.
>
> what's pretty strange is that every kind of deletion seems to either
> trigger an exception or a segfault, yet the variants throwing exceptions
> work otherwise.
>
> the problem is that when doing
>
> self.toolView = kate.mainInterfaceWindow().createToolView(…)
> self.console = TerminalWidget(parent=self.toolView, kate=kate)
>
>  we have a widget hierarchy: main window → tool view → console
>
> and shutting down kate before shutting down some iPython internal (ZMQ)
> seems to create a segfault.
>
> yet when deleting the console first, we get a RuntimeError.
> ------------------------------
>
> one problem might be that C++'s delete doesn't work with python's del –
> widget.deleteLater() doesn't call widget.*del*(), while "del widget"
> doesn't call ~WidgetClass()
>
> since ToolView's destructor calls MainWindow::toolViewDeleted(), we need
> to do it Qt's way – a "del self.toolView" leaves a reference to it in
> kate's main window, which prevents deletion.
>
> but since we also need to close the console first, we have a problem. and
> not even the following cuts it…
>
> del self.console #doesn't call __del__, we stil have a reference by it being self.toolView's child
> self.toolView.setCentralWidget(None) #now it should be deleted
> self.toolView.deleteLater()
>
> help?
>
> _______________________________________________
> KWrite-Devel mailing list
> KWrite-Devel@kde.org
> https://mail.kde.org/mailman/listinfo/kwrite-devel
>
>

[Attachment #5 (text/html)]

<div dir="ltr">the problem already solved for color_tools and cmake_utils (at least) \
-- rebuild `kate`...<br><br></div><div class="gmail_extra"><br><br><div \
class="gmail_quote">On Tue, Feb 18, 2014 at 7:55 PM, Philipp A. <span \
dir="ltr">&lt;<a href="mailto:flying-sheep@web.de" \
target="_blank">flying-sheep@web.de</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr"><div><p style="margin:1.2em 0px!important">Hi, \
when unloading the ipython console (in exit or when unchecking it), kate \
segfaults.</p>

<p style="margin:1.2em 0px!important">what's pretty strange is that every kind of \
deletion seems to either trigger an exception or a segfault, yet the variants \
throwing exceptions work otherwise.</p> <p style="margin:1.2em 0px!important">the \
problem is that when doing</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-wrap;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)">self.toolView = \
kate.mainInterfaceWindow().createToolView(…) self.console = \
TerminalWidget(parent=self.toolView, kate=kate) </code></pre>
<p style="margin:1.2em 0px!important"> we have a widget hierarchy: main window → \
tool view → console</p> <p style="margin:1.2em 0px!important">and shutting down \
kate before shutting down some iPython internal (ZMQ) seems to create a segfault.</p> \
<p style="margin:1.2em 0px!important">yet when deleting the console first, we get a \
RuntimeError.</p> <hr>
<p style="margin:1.2em 0px!important">one problem might be that C++'s delete doesn't \
work with python's del – widget.deleteLater() doesn't call \
widget.<strong>del</strong>(), while "del widget" doesn't call ~WidgetClass()</p>



<p style="margin:1.2em 0px!important">since ToolView's destructor calls \
MainWindow::toolViewDeleted(), we need to do it Qt's way – a "del self.toolView" \
leaves a reference to it in kate's main window, which prevents deletion.</p>



<p style="margin:1.2em 0px!important">but since we also need to close the console \
first, we have a problem. and not even the following cuts it…</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-wrap;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)"><span \
style="color:rgb(51,51,51);font-weight:bold">del</span> self.console <span \
style="color:rgb(153,153,136);font-style:italic">#doesn't call __del__, we stil have \
a reference by it being self.toolView's child </span> \
self.toolView.setCentralWidget(<span style="color:rgb(0,134,179)">None</span>) <span \
style="color:rgb(153,153,136);font-style:italic">#now it should be deleted</span> \
self.toolView.deleteLater() </code></pre>
<p style="margin:1.2em 0px!important">help?</p>
</div></div>
<br>_______________________________________________<br>
KWrite-Devel mailing list<br>
<a href="mailto:KWrite-Devel@kde.org">KWrite-Devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/kwrite-devel" \
target="_blank">https://mail.kde.org/mailman/listinfo/kwrite-devel</a><br> \
<br></blockquote></div><br></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