Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting SIGSEGV on "finished" signal from QNetwowkAccessManager

Getting SIGSEGV on "finished" signal from QNetwowkAccessManager

Scheduled Pinned Locked Moved General and Desktop
qnetworkaccessmqnetreply
13 Posts 2 Posters 5.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi and welcome to devnet,

    connect(mpNetManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished()));

    You are missing the parameter of downloadFinished

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Fernando
      wrote on last edited by SGaist
      #3

      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]

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        What do you get if you run your application through a debugger ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Fernando
          wrote on last edited by
          #5

          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.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Can you check with a tool like Dependency Walker the libraries you are currently linking to ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Fernando
              wrote on last edited by
              #7

              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

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                That part looks good

                Then let's get step by step. Does it also fail if you comment out the network stuff ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Fernando
                  wrote on last edited by Fernando
                  #9

                  It debugs nicely without

                  mpNetManager->get(netRequest);

                  And it runs nicely (even with mpNetManager->get(netRequest)) when not debugging (even if the build was in debug mode).
                  To me, it's a bug in the debugger :-) , at least under Windows7-64.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    Using Qt's MinGW package ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      Fernando
                      wrote on last edited by
                      #11

                      Sorry, I was out of town.

                      Yes, using Qt's MinGW package (I don't have and don't like Visual Studio :-) ).

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        So you have MinGW 4.9 ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • F Offline
                          F Offline
                          Fernando
                          wrote on last edited by
                          #13

                          Yes, MinGW 4.9.1.
                          Do you think I should file a bug report?

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved