Developer Blog -
  • Skipper - The ORM Designer
  • VsBuilds - Parallel building
  • Pulpo - Free Skipper CLI

Tag: #hang-up

Qt5 application hangs-up when QNetworkAccessManager and QEventLoop is used on Mac OS

To be more specific, problem occurs only in very specific circumstances. It's in situation, when application is compiled as console-app and it's compiled on Mac OS X version older than 10.9:

CONFIG -= gui<br />
CONFIG -= console<br />

and when you're using QEventLoop::exec in mode processing all events except user events (QEventLoop::ExcludeUserInputEvents):

<p>//it's only demonstration, not full code...<br />
QNetworkAccessManager manager; ...<br />
QNetworkRequest request; ...<br />
QNetworkReply *reply = manager-&gt;post(request,arData);<br />
<p>eventLoop.exec(QEventLoop::ExcludeUserInputEvents);<br />

In this situation, application hangs-up. When the application is compiled with GUI mode or when application is compiled on Linux/Windows (no matter if gui or console), everything works find. To fix this problem, it's necessary to implement hack similar to this (simplified version):

   bool bAllowUserInputEvents = false;</p>
<p>#if defined(PLATFORM_MACOS) &amp;&amp; defined(AX_APP_CONSOLE)<br />
   bAllowUserInputEvents = true;<br />
<p>  if ( bAllowUserInputEvents == false )<br />
    eventLoop.exec(QEventLoop::ExcludeUserInputEvents);<br />
  else<br />
    eventLoop.exec(QEventLoop::AllEvents);<br />

17 Sep 2014