title: Qt5Cored!Qobject::disconnect... read access violation at 0x0
body: <p>The following describes the issue and what I did to "correct" them.  This runtime event required a few hours of time to resolve. As the site is one of my favorite sources of information, thought this might benefit someone. </p>
  
  <p>I am sure this exception was created by my misunderstanding of QObjectCleanupHandler. Any constructive comments on a practical implementation of QObjectCleanupHandler would be appreciated. </p>
  
  <p>-- Added QObjectCleanupHandler with QPointer&lt;> to a MDI subwindow and a worker class. </p>
  
  <ul>
  <li>run-DEBUG the application.</li>
  </ul>
  
  <p>at the end of the run: </p>
  
  <p>A dialog is raised with what appears to be assembly stack data. </p>
  
  <p>Checked the debug log in QT Creator Menu: Windows\Views\Debugger Log\</p>
  
  <p>Log Snippet:</p>
  
  <p>Move to bottom </p>
  
  <p>::::</p>
  
  <p>Snippet:</p>
  
  <p>Move to bottom </p>
  
  <blockquote>
    <p>dState changed from InferiorRunRequested(10) to InferiorRunOk(11)
    [master]  (1d84.1720): Access violation - code c0000005 (first chance)
    s sException at 0x67343a9c, code: 0xc0000005: read access violation
    at: 0x0, flags=0x0 (first chance) at
    c:\work\build\qt5_workdir\w\s\qtbase\src\corelib\kernel\qobject.cpp:2813
    First chance exceptions are reported before any exception handling. 
    This exception may be expected and handled.  eax=03f160f1 ebx=00000000
    ecx=03f3b728 edx=feeefeee esi=00000005 edi=00000000  eip=67343a9c
    esp=0046d1b8 ebp=0046d340 iopl=0         nv up ei pl nz na po nc 
    cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b<br>
    efl=00010202  Qt5Cored!QObject::disconnect+0x2bc:   2813 67343a9c 8b02
    mov     eax,dword ptr [edx] ds:002b:feeefeee=???????? s sException at
    0x67343a9c, code: 0xc0000005: read access violation at: 0x0, flags=0x0
    (first chance) dNOTE: INFERIOR SPONTANEOUS STOP sStopped. dState
    changed from InferiorRunOk(11) to InferiorStopOk(14) [master] 
    Resolving symbol: Qt5Cored!QObject::disconnect... 
  </blockquote>
  
  <hr>
  
  <p>Source Code Snippet responsible for the exception:</p>
  
  <pre><code>QThread *thread = new QThread;
  QPointer&lt;vcSharedDataQt&gt; worker = new vcSharedDataQt();
  trackObject(worker);
  worker-&gt;movetothread(thread); 
  </code></pre>
  
  <p>trackObject() method is a private field on the QMdiSubWindow  </p>
  
  <pre><code>class &lt;form&gt; 
  {
  
   private:
  
     QObjectCleanupHandler trackObject(QObject obj);
  
  
  ::: etc.
  </code></pre>
  
  <p>Corrective Action:</p>
  
  <p>Source Code Snippet Changed to:</p>
  
  <pre><code>QThread *thread = new QThread;
  QPointer&lt;vcSharedDataQt&gt; worker = new vcSharedDataQt();
  worker-&gt;movetothread(thread); 
  </code></pre>
  
  <p>/*
     removed all instances of QObjectCleanupHandler in all classes.
  */</p>
  
  <p>QT Environment Defined in Exception: <a href="https://stackoverflow.com/questions/21568786/qt-kernalbaseraiseexception-at-0x759fc41f">QT KernelBase!RaiseException at 0x759fc41f</a></p>
  
  <hr>