Wow, I need help, I have no clue on what is going on. Thanks in advance!
I have a QGUIApplication, getting a singleton from class X. Class X has a QNetworkAccessManager.
I don't use the Post() method, it's all good when I close the window. But, as soon as I use the Post method(), when I close the window, I get a segfault. The only info I get from the stack is this:
ntdll!RtlFreeHeap
ucrtbase!free
LIBEAY32!CRYPTO_free
LIBEAY32!CRYPTO_free seems to be related to SSL. I have nothing about SSL in my code.
In the code, Post() works fine, I'm posting a QByteArray, I receive the reply in the slot called by the Finished() signal.
Here some code:
Main.cpp
//AboutToClose() calls Finalize() in ClassX
QObject::connect(&app,
SIGNAL(aboutToQuit
()),
&OtherClass,
SLOT(AboutToClose
()));
//AboutToClose() calls Finalize() in ClassX
QObject::connect(&app, SIGNAL(aboutToQuit()), &OtherClass, SLOT(AboutToClose()));
To copy to clipboard, switch view to plain text mode
Class X.h
#include <QNetworkAccessManager>
#include <QNetworkReply>
private:
QNetworkAccessManager* m_Manager;
public Q_SLOTS:
void onFinished(QNetworkReply* pReply);
#include <QNetworkAccessManager>
#include <QNetworkReply>
private:
QNetworkAccessManager* m_Manager;
public Q_SLOTS:
void onFinished(QNetworkReply* pReply);
To copy to clipboard, switch view to plain text mode
Class X.cpp
void ClassX::InitMyStuff()
{
m_Manager = new QNetworkAccessManager(this);
if(!connect(m_Manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply*)))) { ASSERT(FALSE); }
PostData();
}
void ClassX::PostData()
{
QNetworkRequest request
= QNetworkRequest
(QUrl(sUrl
));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlenconded");
m_Manager->post(request, file.readAll());
file.close();
}
void ClassX::onFinished(QNetworkReply *pReply)
{
pReply->close();
pReply->deleteLater();
}
// Look above at Main.cpp to see how this is called
void ClassX::Finalize()
{
m_Manager->disconnect();
delete m_Manager;
m_Manager = NULL;
}
void ClassX::InitMyStuff()
{
m_Manager = new QNetworkAccessManager(this);
if(!connect(m_Manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply*)))) { ASSERT(FALSE); }
PostData();
}
void ClassX::PostData()
{
QFile file(...);
...file.open(QIODevice::ReadOnly)...
QString sUrl(BASE_URL);
QNetworkRequest request = QNetworkRequest(QUrl(sUrl));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlenconded");
m_Manager->post(request, file.readAll());
file.close();
}
void ClassX::onFinished(QNetworkReply *pReply)
{
pReply->close();
pReply->deleteLater();
}
// Look above at Main.cpp to see how this is called
void ClassX::Finalize()
{
m_Manager->disconnect();
delete m_Manager;
m_Manager = NULL;
}
To copy to clipboard, switch view to plain text mode
Bookmarks