title: Destruction of QObjects
body: <p>My program sometimes gives Segmentation Fault at the last statement in main function.</p>
  <p><code>return a.exec();</code></p>
  <p>I think problem is with order of destruction. <a href="http://harmattan-dev.nokia.com/docs/library/html/qt4/objecttrees.html" rel="nofollow noreferrer">Qt documentation</a> says that</p>
  <blockquote>
  <p>No QObject is deleted twice, regardless of the order of destruction.</p>
  </blockquote>
  <p>But when I tried following code it gives segmentation fault.</p>
  <pre><code>QWidget* first = new QWidget;
  QWidget* second = new QWidget(first);
  delete first;
  delete second;
  </code></pre>
  <p>I know when <code>first</code> is deleted, it deletes its children <code>second</code> also.</p>
  <p>So why does Documentation says that order of destruction doesn't matter?</p>
  <p>Should we be always careful about deleting child object?</p>
  <p>I am downloading a file with QNetworkAccessManager, when file download is completed I want to delete <code>Downloader</code> object which inherits <code>QObject</code> to free memory. But if I delete it causes segmentation fault.</p>