<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Hi Ray,</p>
<p>I do not know if it will help your case. I was getting rid of some crashes on exit by deleting all widgets that had no parent. For instance, when closing the QMainWindow by doing:</p>
<p> def closeEvent(self, event):<br /> if __name__ == "__main__":<br /> app = qt.QApplication.instance()<br /> allWidgets = app.allWidgets()<br /> for widget in allWidgets:<br /> try:<br /> # we cannot afford to crash here<br /> if id(widget) != id(self):<br /> if widget.parent() is None:<br /> widget.close()<br /> except:<br /> _logger.debug("Error closing widget")<br /> return qt.QMainWindow.closeEvent(self, event)</p>
<p>Best regards,</p>
<p>Armando</p>
<p>On 25.05.2020 19:48, Raymond Osborn wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->I added a call to QtWidgets.QApplication.instance().processEvents() in order to force adjustResize() to work when switching tabs (that's another story). It succeeded in fixing my resize issue, but now it triggers a segfault when I exit the application. This seemed to be related to the bug described in <a href="https://www.riverbankcomputing.com/static/Docs/PyQt5/gotchas.html#crashes-on-exit">https://www.riverbankcomputing.com/static/Docs/PyQt5/gotchas.html#crashes-on-exit</a>. One fix, suggested by @ekhumoro on stackoverflow (<a href="https://stackoverflow.com/questions/59120337/why-does-pyqt-sometimes-crash-on-exit">https://stackoverflow.com/questions/59120337/why-does-pyqt-sometimes-crash-on-exit</a>) was to delete the main window and the app first, but that doesn't seem to fix it. I am running PyQt 5.12 because that is the last version supported by conda, so I can't test the one-exit fix in v5.13, and my users probably wouldn't have it installed anyway. It happens on Macs and linux.
<div> </div>
<div>What I am asking is if there are additional things to try in addition to @ekhumoro's suggestion? Basically he suggests doing something like:</div>
<div> </div>
<div>
<pre class="lang-py prettyprinted prettyprint" style="margin-top: 0px; margin-bottom: 1em; padding: 12px 8px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit; width: auto; max-height: 600px; overflow: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; color: #242729; word-wrap: normal; caret-color: #242729;"><code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; white-space: inherit;"><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--blue-800);">def</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);"> main</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">():</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">
app </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">=</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);"> </span><span class="typ" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: #2b91af;">QApplication</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">(</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">sys</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">.</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">argv</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">)</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">
main_window </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">=</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);"> </span><span class="typ" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: #2b91af;">MainWindow</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">()</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">
main_window</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">.</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">show</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">()</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">
app</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">.</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">exec_</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">()</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">
</span><span class="com" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-400);"># ensure correct deletion order</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">
</span><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--blue-800);">del</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);"> main_window</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);">,</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; color: var(--black-750);"> app</span></code></pre>
<div>Does anyone understand why the crash only occurs if I have calls to processEvents() in the code? It never happens when I remove them.</div>
</div>
<div> </div>
<div>Thanks,</div>
<div>Ray</div>
<div> </div>
<div> </div>
</blockquote>
</body></html>