title: LabVIEW blocking Qt signals?
body: <p>I have a LabVIEW 8.6 program that is using a DLL written in Qt; the DLL listens to a TCP port for incoming messages and updates some internal data.  My LabVIEW program calls into the DLL occasionally to read the internal data.  The DLL works perfectly (i.e., receives data from the TCP port) with another Qt program.  However, it does not work at all with my LabVIEW program.</p>
  
  <p>I've attached a debugger to the DLL and can see calls from LabVIEW going into it -- my function for getting the internal data is being called and I can step through it.  The code that gets the data from the TCP is never called though; it looks like the signal for incoming data on the TCP port is never triggered. </p>
  
  <p>I know this sounds like a Qt issue but the DLL works perfectly with another Qt program.  Unfortunately, it fails miserably with LabVIEW.  </p>
  
  <p>One theory:</p>
  
  <ul>
  <li><p>The event loop is not running when LabVIEW calls the DLL</p>
  
  <ul>
  <li>In the Qt DLL's run() function, I call socket->waitForDisconnected(). Perhaps the DLL is not processing incoming events because the event loop is not running?  If I call exec() to start the event loop, LabVIEW crashes (LabVIEW 8.6 Development System has encountered a problem and needs to close."):</li>
  </ul></li>
  </ul>
  
  <pre>
      AppName: labview.exe     AppVer: 8.6.0.4001     ModName: qtcored4.dll
      ModVer: 4.5.1.0     Offset: 001af21a
  </pre>
  
  <ul>
  <li>Perhaps when I call the DLL from another Qt program, that program's event loop is allowing for the TCP signal to be seen by the DLL.  Unfortunately, kicking off the event loop in the DLL takes down LabVIEW.</li>
  </ul>
  
  <p>Any thoughts on how to keep signals running in the DLL when LabVIEW is the calling program? </p>
  
  <p><strong>EDIT</strong> Debug trace of the exec() call:</p>
  
  <pre><code>QThread::exec() -&gt; eventLoop.exec() -&gt; if (qApp-&gt;thread() == thread())
  
  in the call to 
  
  QObject::thread() { 
     return d_func()-&gt;threadData-&gt;thread;
  }
  </code></pre>
  
  <p>The macro Q_DECLARE_PRIVATE(QObject), the second call, triggers the crash.</p>
  
  <p><strong>EDIT 17 Aug 2009:</strong> Status update</p>
  
  <p>After two days of trying various ways to get this to work I decided to implement a TCP listener directly in LabVIEW.  My LabVIEW application sends data out via the DLL and receives data in via TCP.  All is working well.</p>
  
  <hr>
  
  <p>This question was cross-posted on <a href="http://forums.ni.com/ni/board/message?board.id=170&amp;thread.id=431779" rel="nofollow noreferrer">http://forums.ni.com/ni/board/message?board.id=170&amp;thread.id=431779</a></p>