<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Feb 6, 2020, at 7:55 AM, Jason H <<a href="mailto:jhihn@gmx.com" class="">jhihn@gmx.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div style="font-family: Verdana;font-size: 12.0px;" class=""><div class="">It is subject to reference counting semantics in python.</div>

<div class="">#declare and and b as object with properties b and a, respectively, then do:</div>

<div class="">a.b = b</div>

<div class="">b.a = a</div>

<div class=""> </div>

<div class="">a and b are now impossible to delete. Next: </div>

<div class="">a.b = None</div>

<div class="">del(a) #nope</div>

<div class="">del(b) #ok</div></div></div></div></blockquote><div><br class=""></div><div>Ok, yeah, that’s a good point - there are cases where you can run into problems in python that perhaps wouldn’t be an issue in C. However my question is about the “normal” case, where you are just deleting a basic Qt object that has children objects. In C, this results in the deletion of the child objects as well, due to some Qt “magic”. So I can just call delete on the top-level object, and know that all children will be deleted as well. Is the same true in Python with PySide2, such that calling del in python on a Qt object is exactly equivalent to calling delete on an identical object in C, assuming no corner cases?</div><div><br class=""></div><div>For a little background, I have an application that makes heavy use of multiprocessing to be able to generate images (using QWidgets to “build” the image) and save them to disk in parallel. The creation of the widgets HAS to be in parallel, thus multiprocessing. However, it seems that if I do any work with QWidgets on the main process, that somehow pollutes the main process such that the child processes now crash at some point (and it’s REALLY difficult to track down where). On the other hand, if I *don’t* do anything with QApplication/QWidgets in the main process, the child processes work fine. So I’m trying to make sure I’m “cleaning up” properly to avoid crashing after doing stuff in the main process, but to do that I need to be sure everything I created is properly deleted - including the main QApplication.</div><div><br class=""></div><div>And yes, I know you can only create widgets on the main thread. Please note that I am NOT using threads, as threads do not allow true multitasking. I am using processes, and only working with widgets on the main thread of any given process. So that much works, and is fine.</div><div><br class=""></div><div><div>---</div><div>Israel Brewster<br class="">Software Engineer<br class="">Alaska Volcano Observatory <br class="">Geophysical Institute - UAF <br class="">2156 Koyukuk Drive <br class="">Fairbanks AK 99775-7320</div><div>Work: 907-474-5172<br class="">cell:  907-328-9145</div></div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div style="font-family: Verdana;font-size: 12.0px;" class="">

<div class=""> 
<div class=""> 
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="margin:0 0 10px 0;" class=""><b class="">Sent:</b> Wednesday, February 05, 2020 at 7:23 PM<br class="">
<b class="">From:</b> "Israel Brewster" <<a href="mailto:ijbrewster@alaska.edu" class="">ijbrewster@alaska.edu</a>><br class="">
<b class="">To:</b> <a href="mailto:pyside@qt-project.org" class="">pyside@qt-project.org</a><br class="">
<b class="">Subject:</b> [PySide] Is del in python completely equivalent to delete in c for Qt objects?</div>

<div name="quoted-content" class="">
<div class="">In C++ Qt code, if I do something like the following:
<div class=""> </div>

<div class="">QMainWindow *win=new QMainWindow()</div>

<div class=""><add other objects to win/do stuff with it></div>

<div class="">delete win</div>

<div class=""> </div>

<div class="">The QMainWindow, as well as all of its children will be deleted, with the latter half of that statement being the important part. Of course, this child deletion is a Qt thing and not a C thing, as typically calling delete only deletes the thing it was called on. As such, I was wanting to confirm that, when using python/PySide2, calling del on a Qt object would trigger the same child deletion algorithm that delete does in C.
<div class="">
<div class="">
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class="">---</div>

<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class="">Israel Brewster<br class="">
Software Engineer<br class="">
Alaska Volcano Observatory <br class="">
Geophysical Institute - UAF <br class="">
2156 Koyukuk Drive <br class="">
Fairbanks AK 99775-7320</div>

<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class="">Work: 907-474-5172<br class="">
cell:  907-328-9145</div>
</div>
</div>
</div>
_______________________________________________ PySide mailing list <a href="mailto:PySide@qt-project.org" class="">PySide@qt-project.org</a> <a href="https://lists.qt-project.org/listinfo/pyside" target="_blank" class="">https://lists.qt-project.org/listinfo/pyside</a></div>
</div>
</div>
</div>
</div></div></div>
</div></blockquote></div><br class=""></body></html>