title: QMYSQLResult::cleanup: unable to free statement handle
body: <p>I'm trying to use a thread to bring data from a MySQL database, but after a call to:</p>
  
  <pre><code>QThread* thread = new QThread;
  Beacon *beacon = new Beacon(m_db, begin, end);
  beacon-&gt;moveToThread(thread);
  connect(beacon, &amp;Beacon::values, this, &amp;Tm::insertRow);
  connect(beacon, &amp;Beacon::finished, thread, &amp;QThread::quit);
  connect(beacon, &amp;Beacon::finished, beacon, &amp;Beacon::deleteLater);
  connect(thread, &amp;QThread::finished, thread, &amp;QThread::deleteLater);
  connect(thread, &amp;QThread::started, beacon, &amp;Beacon::executeQuerySmooth);
  connect(beacon, &amp;Beacon::finished, this, &amp;Tm::finished);
  thread-&gt;start();
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>QMYSQLResult::cleanup: unable to free statement handle
  </code></pre>
  
  <p>And the next time a try to use the connection I get:</p>
  
  <pre><code>QSqlError("2006", "QMYSQL: Unable to execute query", "MySQL server has gone away")
  </code></pre>
  
  <p>What might be happening?</p>