title: How delete and deleteLater works with regards to signals and slots in Qt?
body: <p>There is an object of class QNetworkReply. There is a slot (in some other object) connected to its finished() signal. Signals are synchronous (the default ones). There is only one thread.</p>
  
  <p>At some moment of time I want to get rid of both of the objects. No more signals or anything from them. I want them gone.
  Well, I thought, I'll use</p>
  
  <pre><code>delete obj1; delete obj2;
  </code></pre>
  
  <p>But can I really?
  The specs for ~QObject say:</p>
  
  <blockquote>
    <p>Deleting a QObject while pending events are waiting to be delivered can cause a crash.</p>
  </blockquote>
  
  <p>What are the 'pending events'?
  Could that mean that while I'm calling my <code>delete</code>, there are already some 'pending events' to be delivered and that they may cause a crash and I cannot really check if there are any?</p>
  
  <p>So let's say I call:</p>
  
  <pre><code>obj1-&gt;deleteLater(); obj2-&gt;deleteLater();
  </code></pre>
  
  <p>To be safe.</p>
  
  <p>But, am I really safe? The <code>deleteLater</code> adds an event that will be handled in the main loop when control gets there. Can there be some pending events (signals) for <code>obj1</code> or <code>obj2</code> already there, waiting to be handled in the main loop <em>before</em> deleteLater will be handled? That would be very unfortunate. I don't want to write code checking for 'somewhat deleted' status and ignoring the incoming signal in all of my slots.</p>