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

List:       kwrite-devel
Subject:    Destroying toolviews in python
From:       "Philipp A." <flying-sheep () web ! de>
Date:       2014-02-18 15:55:35
Message-ID: CAN8d9gmiQddxOFq29e1smoGnrWo6+M93MiX_dN=VMqH63Cq0xA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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?

[Attachment #5 (text/html)]

<div dir="ltr"><div style class="markdown-here-wrapper" \
id="markdown-here-wrapper-951321"><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;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-python">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;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-python"><span \
style="color:rgb(51,51,51);font-weight:bold" class="keyword">del</span> self.console \
<span style="color:rgb(153,153,136);font-style:italic" class="comment">#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)" \
class="built_in">None</span>) <span style="color:rgb(153,153,136);font-style:italic" \
class="comment">#now it should be deleted</span> self.toolView.deleteLater()
</code></pre>
<p style="margin:1.2em 0px!important">help?</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