Getting SIGSEGV on "finished" signal from QNetwowkAccessManager
-
Hi and welcome to devnet,
connect(mpNetManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished()));
You are missing the parameter of downloadFinished
-
You're right, sorry.
Corrected .cpp source (still the same problem):
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); initializeNetwork(); testDownload(); } MainWindow::~MainWindow() { delete ui; mpNetManager->deleteLater(); } void MainWindow::initializeNetwork() { mpNetManager = new QNetworkAccessManager; } void MainWindow::testDownload() { if (mpNetManager) { QNetworkRequest netRequest; QUrl downloadURL(TEST_URL); netRequest.setUrl(downloadURL); connect(mpNetManager, SIGNAL(finished(QNetworkReply * )), this, SLOT(downloadFinished(QNetworkReply * ))); mpNetManager->get(netRequest); } } void MainWindow::downloadFinished (QNetworkReply* pNetReply) { if (pNetReply) { if(pNetReply->error()) { qDebug() << "ERROR!"; qDebug() << pNetReply->errorString(); } else { QString qsDownloadPath = "downloaded.txt"; QFile *pOutFile = new QFile(qsDownloadPath); if(pOutFile->open(QFile::WriteOnly)) { pOutFile->write(pNetReply->readAll()); pOutFile->flush(); pOutFile->close(); } delete pOutFile; qDebug() << "Download finished"; qDebug() << "Content written to"; qDebug() << qsDownloadPath; } pNetReply->deleteLater(); } }
[edit: Added missing coding tags SGaist]
-
What do you get if you run your application through a debugger ?
-
As I stated, when i launch the debugger, as soon as the "finished" signal fires I get the message
"The inferior stopped because it received a signal from the operating system
Signal name: SIGSEGV
Signal meaning: Segmentation Fault"This is from C:\Windows\SysWOW64\ntdll.dll, instruction "rtlmovmemory"
This only happens while debugging: the program runs fine in Release.
-
Can you check with a tool like Dependency Walker the libraries you are currently linking to ?
-
Sure:
LIBGCC_S_DW2-1.DLL
QT5CORED.DLL
QT5NETWORKD.DLL
QT5WIDGETSD.DLL
API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL
DCOMP.DLL
IESHIMS.DLL -
That part looks good
Then let's get step by step. Does it also fail if you comment out the network stuff ?
-
-
Using Qt's MinGW package ?
-
So you have MinGW 4.9 ?