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

List:       kde-core-devel
Subject:    Re: New System Settings
From:       Thomas =?iso-8859-1?q?L=FCbking?= <thomas.luebking () web ! de>
Date:       2009-05-23 0:47:28
Message-ID: 200905230247.28913.thomas.luebking () web ! de
[Download RAW message or body]

Am Saturday 23 May 2009 schrieb Ben Cooksley:
> If I made it a singleton, then I would have to reparent it as views
> needed it, which would lead to a really nasty crash upon closing
> because the module view would try to destroy the modules ( since they
> would have to be held in a internal list of some description ) except
> the reparented one had already been destroyed by Qt automatically.
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.
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)

Thomas

[Attachment #3 (text/html)]

<!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> &gt; If I made \
it a singleton, then I would have to reparent it as views<br> &gt; needed it, which \
would lead to a really nasty crash upon closing<br> &gt; because the module view \
would try to destroy the modules ( since they<br> &gt; would have to be held in a \
internal list of some description ) except<br> &gt; 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&lt;T&gt; class handling this \
for you so instead "QWidget *w" you can just use "QPointer&lt;QWidget&gt; 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>



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

Configure | About | News | Add a list | Sponsored by KoreLogic