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. QNetworkRequest / QNetworkReply issue with 5.13.1?
Forum Updated to NodeBB v4.3 + New Features

QNetworkRequest / QNetworkReply issue with 5.13.1?

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 656 Views
  • 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.
  • Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Where exactly does it crash and why do you spin an eventloop instead properly relying on signals/slots?

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    1 Reply Last reply
    1
    • A Offline
      A Offline
      AwesomeBoxhead
      wrote on last edited by AwesomeBoxhead
      #3

      Why do you spin an eventloop instead properly relying on signals/slots?

      When I first started programming with Qt I relied heavily on examples that I found over the internet. I could not find any good examples of retrieving API JSON data on the Qt website and had to rely on other sources. The code you see is a combination of examples I found that I got to work for the past 2 years. Now, with the advent of 5.13.1, the code does not work and will probably need to be updated to the proper signal / slot procedure which may fix the crash issue.

      Where does it crash?

      The function crashes the SECOND time it runs the function right at:

      reply->deleteLater();
      

      I added a qDebug() right before it and after it. The first time through both qDebug()s echo'd out the info. The second time through only the first qDebug() echo'd out info and then crashed on the reply->deleteLater() line.

      I would like to Add

      One thing I would like to add, not sure if this would play a part. All these calls are being made from child windows (classes). I create a pointer object in a child window (class) in the construct function that points to the MainWindow class, then I call the api GET function that resides within the MainWindow class like:

      //mw is a pointer to the MainWindow class
      QJsonObject api_info = mw->getRequest("some/api/link").object();
      
      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @AwesomeBoxhead said in QNetworkRequest / QNetworkReply issue with 5.13.1?:

        reply->readAll()

        So readAll() works but deleteLater() crashes? Please show us the backtrace.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AwesomeBoxhead
          wrote on last edited by
          #5

          That is correct.

          The first time the function "MainWindow::getRequest" is ran:

          • qDebug() before deleteLater() echo'd the JSON object returned from json = QJsonDocument::fromJson(reply->readAll());
          • deleteLater() runs
          • qDebug() runs after deleteLater()

          The second time the function runs:

          • qDebug() before deleteLater() echo'd the JSON object returned from json = QJsonDocument::fromJson(reply->readAll());
          • deleteLater() runs and CRASH

          In regards to the backtrace, I am having one heck of a time trying to find documentation on how to do this. I do not want to deviate this topic with how to generate a backtrace, so I will open a new topic and will get back with you once I become more educated, lol

          Thanks for your time looking at this!

          ~Dustin

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Can you please add the qDebug() statements in your code?
            And for getting the backtrace see here: https://doc.qt.io/qtcreator/creator-debug-mode.html

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AwesomeBoxhead
              wrote on last edited by
              #7

              I edited the original post and added the qDebug() before AND after the reply->deleteLater() like I have in my code.

              I activated debug mode which is really cool.

              These are the steps I followed within debug mode:

              <app launched>
              Clicked the menu
              Clicked Login link
              <the login window opens>
              Clicked Login button
              <error window opens, failed logging in>
              Clicked Login button again
              <crash>

              Within debug mode, I received the following error message upon clicking the button for a second time.

              signal-received.png

              Here is the full stacktrace. Gonna be honest, I have no idea what I am looking at with this stacktrace thing, lol. I'm gonna be looking into how to work with this. This debug mode is very neat. Wish I knew about this feature awhile ago, lol.

              1 vtable for QEventDispatcherWin32Private 0x6bcdf840
              2 DirectShowIOReader::readyRead directshowioreader.cpp 347 0x31a5689a
              3 DirectShowIOReader::customEvent directshowioreader.cpp 337 0x31a56c6f
              4 QObject::event qobject.cpp 1282 0x6b94b9d0
              5 QApplicationPrivate::notify_helper qapplication.cpp 3703 0x1ce5832e
              6 QApplication::notify qapplication.cpp 3059 0x1ce5f3d1
              7 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1095 0x6b91eafa
              8 QCoreApplication::sendEvent qcoreapplication.cpp 1490 0x6b91ed22
              9 DirectShowEventLoop::processEvents directshoweventloop.cpp 147 0x31a525e9
              10 DirectShowEventLoop::customEvent directshoweventloop.cpp 127 0x31a5270b
              11 QObject::event qobject.cpp 1282 0x6b94b9d0
              12 QApplicationPrivate::notify_helper qapplication.cpp 3703 0x1ce5832e
              13 QApplication::notify qapplication.cpp 3059 0x1ce5f3d1
              14 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1095 0x6b91eafa
              15 QCoreApplication::sendEvent qcoreapplication.cpp 1490 0x6b91ed22
              16 QCoreApplicationPrivate::sendPostedEvents qcoreapplication.cpp 1840 0x6b9230db
              17 QEventDispatcherWin32::sendPostedEvents qeventdispatcher_win.cpp 1098 0x6b9719a1
              18 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 81 0x2afa92d0
              19 qt_internal_proc qeventdispatcher_win.cpp 245 0x6b9749ab
              20 USER32!CallWindowProcW 0x7ff86d6263ed
              21 USER32!DispatchMessageW 0x7ff86d625de2
              22 QEventDispatcherWin32::processEvents qeventdispatcher_win.cpp 639 0x6b97415c
              23 QWindowsGuiEventDispatcher::processEvents qwindowsguieventdispatcher.cpp 74 0x2afa92b7
              24 QEventLoop::processEvents qeventloop.cpp 138 0x6b91d107
              25 QEventLoop::exec qeventloop.cpp 225 0x6b91d525
              26 QDialog::exec qdialog.cpp 602 0x1d03e75e
              27 loginWindow::escErrorMsg loginwindow.cpp 43 0x4106c0
              28 loginWindow::on_btn_login_clicked loginwindow.cpp 71 0x410a2d
              29 loginWindow::qt_static_metacall moc_loginwindow.cpp 92 0x41ff28
              30 loginWindow::qt_metacall moc_loginwindow.cpp 139 0x420173
              31 QMetaObject::metacall qmetaobject.cpp 309 0x6b9283b4
              32 QMetaObject::activate qobject.cpp 3825 0x6b94a1a3
              33 QMetaObject::activate qobject.cpp 3660 0x6b94a42c
              34 QAbstractButton::clicked moc_qabstractbutton.cpp 313 0x1cf413e7
              35 QAbstractButtonPrivate::emitClicked qabstractbutton.cpp 414 0x1cf41602
              36 QAbstractButtonPrivate::click qabstractbutton.cpp 407 0x1cf42ba0
              37 QAbstractButton::mouseReleaseEvent qabstractbutton.cpp 1011 0x1cf42e41
              38 QWidget::event qwidget.cpp 8959 0x1ce99958
              39 QAbstractButton::event qabstractbutton.cpp 968 0x1cf43ffc
              40 QPushButton::event qpushbutton.cpp 684 0x1cfd284c
              41 QApplicationPrivate::notify_helper qapplication.cpp 3703 0x1ce5832e
              42 QApplication::notify qapplication.cpp 3163 0x1ce5f6b0
              43 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1095 0x6b91eafa
              44 QCoreApplication::sendSpontaneousEvent qcoreapplication.cpp 1502 0x6b91ed40
              45 QApplicationPrivate::sendMouseEvent qapplication.cpp 2649 0x1ce5ea54
              46 QWidgetWindow::handleMouseEvent qwidgetwindow.cpp 662 0x1ceae7ba
              47 QWidgetWindow::event qwidgetwindow.cpp 281 0x1ceb0c43
              48 QApplicationPrivate::notify_helper qapplication.cpp 3703 0x1ce5832e
              49 QApplication::notify qapplication.cpp 3059 0x1ce5f3d1
              50 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1095 0x6b91eafa
              51 QCoreApplication::sendSpontaneousEvent qcoreapplication.cpp 1502 0x6b91ed40
              52 QGuiApplicationPrivate::processMouseEvent qguiapplication.cpp 2111 0x1979463
              53 QGuiApplicationPrivate::processWindowSystemEvent qguiapplication.cpp 1846 0x197a7fc
              54 QWindowSystemInterface::sendWindowSystemEvents qwindowsysteminterface.cpp 1148 0x19609f3
              55 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 82 0x2afa92d9
              56 qt_internal_proc qeventdispatcher_win.cpp 245 0x6b9749ab
              57 USER32!CallWindowProcW 0x7ff86d6263ed
              58 USER32!DispatchMessageW 0x7ff86d625de2
              59 QEventDispatcherWin32::processEvents qeventdispatcher_win.cpp 639 0x6b97415c
              60 QWindowsGuiEventDispatcher::processEvents qwindowsguieventdispatcher.cpp 74 0x2afa92b7
              61 QEventLoop::processEvents qeventloop.cpp 138 0x6b91d107
              62 QEventLoop::exec qeventloop.cpp 225 0x6b91d525
              63 QCoreApplication::exec qcoreapplication.cpp 1403 0x6b9262e8
              64 QGuiApplication::exec qguiapplication.cpp 1788 0x197080f
              65 QApplication::exec qapplication.cpp 2859 0x1ce58210
              66 qMain main.cpp 10 0x4015c3
              67 WinMain qtmain_win.cpp 97 0x4233ba
              68 __tmainCRTStartup 0x4013c7
              69 WinMainCRTStartup 0x4014cb

              1 Reply Last reply
              0
              • hskoglundH Offline
                hskoglundH Offline
                hskoglund
                wrote on last edited by
                #8

                Hi, if you don't try to login a 2nd time from inside the same dialog box, but instead after the 1st failed login close/cancel the dialog box.
                Then select the login link from the menu again, and try login.
                Does it still crash at deleteLater()?

                A 1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by Christian Ehrlicher
                  #9

                  Since I don't see any call of MainWindow::getRequest() I doubt it happens in this function at all. I would take a look at loginWindow::on_btn_login_clicked() function.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  A 1 Reply Last reply
                  0
                  • hskoglundH hskoglund

                    Hi, if you don't try to login a 2nd time from inside the same dialog box, but instead after the 1st failed login close/cancel the dialog box.
                    Then select the login link from the menu again, and try login.
                    Does it still crash at deleteLater()?

                    A Offline
                    A Offline
                    AwesomeBoxhead
                    wrote on last edited by
                    #10

                    @hskoglund

                    Thanks for taking the time to read!

                    Yes, unfortunately it does still crash even if I try closing the login window after the first failed attempt.

                    My app uses many windows that calls the api. Even upon a successful login, the next window that calls "MainWindow::getRequest()" will crash in version 5.13.1.

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      So there must be some common problem not related to QNetworkRequest (as we can see in the backtrace). I would strip down the program until it no longer crashes.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      1
                      • Christian EhrlicherC Christian Ehrlicher

                        Since I don't see any call of MainWindow::getRequest() I doubt it happens in this function at all. I would take a look at loginWindow::on_btn_login_clicked() function.

                        A Offline
                        A Offline
                        AwesomeBoxhead
                        wrote on last edited by
                        #12

                        @Christian-Ehrlicher

                        That is exactly what I am doing :)

                        Hopefully I will have a very stripped down version of the program I can test soon.

                        Thanks for all your help!

                        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