desktop app crashed when multiple event loops are used in code
-
I am trying to write some data to an url using get request from QNetworkAccessManager class. I am creating an event loop in it. There is another event loop running in the main thread which is the main event loop for the application. The application is getting crashed when it reaches eventLoop.exec(); line in the code below. Any idea why is it happening??
bool Write(QNetworkRequest request) const
{
QEventLoop eventLoop;
connect(networkAccessManager.get(), &QNetworkAccessManager::finished, &eventLoop, &QEventLoop::quit);
int count = 0;
while (count < retryCount)
{
QNetworkReply* reply = networkAccessManager->get(request);
eventLoop.exec();
if (reply != NULL && reply->error() == 0)
return true;
count++;
}
return false;
}**networkAccessManager is the QNetworkAccessManager object.