title: When setting the WA_DeleteOnClose attribute on a Qt MainWindow, the program crashes when deleting the ui pointer
body: <p>I have set the <code>WA_DeleteOnClose</code> widget attribute in a MainWindow.</p>
  
  <pre><code>setAttribute(Qt::WA_DeleteOnClose);
  </code></pre>
  
  <p>However, whenever I close that main window, I get a segfault in its destructor, which only has <code>delete ui;</code></p>
  
  <p>In a nutshell, created a Qt4 GUI Application in Creator, added the <code>setAttribute(Qt::WA_DeleteOnClose);</code> to constructor, program now crashes on exit.</p>