<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Segoe'; font-size:9pt; font-weight:400; font-style:normal;">Am Saturday 23 May 2009 schrieb Ben Cooksley:<br>
> If I made it a singleton, then I would have to reparent it as views<br>
> needed it, which would lead to a really nasty crash upon closing<br>
> because the module view would try to destroy the modules ( since they<br>
> would have to be held in a internal list of some description ) except<br>
> the reparented one had already been destroyed by Qt automatically.<br>
QObjects emit a(n unblockable) signal on destruction that allows you to e.g. unlist them at that moment so you won't try to delete a garbage pointer.<br>
There's even a QPointer<T> class handling this for you so instead "QWidget *w" you can just use "QPointer<QWidget> w" and safely ask "if (w)" or "delete w" anytime then (as w will be NULL for destroyed objects)<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>Thomas</p></body></html>