Results 1 to 4 of 4

Thread: QNetworkAccessManager->Post() causes SIGSEGV on exit

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2016
    Posts
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QNetworkAccessManager->Post() causes SIGSEGV on exit

    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
    Qt Code:
    1. //AboutToClose() calls Finalize() in ClassX
    2. QObject::connect(&app, SIGNAL(aboutToQuit()), &OtherClass, SLOT(AboutToClose()));
    To copy to clipboard, switch view to plain text mode 

    Class X.h
    Qt Code:
    1. #include <QNetworkAccessManager>
    2. #include <QNetworkReply>
    3.  
    4. private:
    5. QNetworkAccessManager* m_Manager;
    6.  
    7. public Q_SLOTS:
    8. void onFinished(QNetworkReply* pReply);
    To copy to clipboard, switch view to plain text mode 

    Class X.cpp
    Qt Code:
    1. void ClassX::InitMyStuff()
    2. {
    3. m_Manager = new QNetworkAccessManager(this);
    4.  
    5. if(!connect(m_Manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply*)))) { ASSERT(FALSE); }
    6.  
    7. PostData();
    8. }
    9.  
    10. void ClassX::PostData()
    11. {
    12. QFile file(...);
    13. ...file.open(QIODevice::ReadOnly)...
    14.  
    15. QString sUrl(BASE_URL);
    16.  
    17. QNetworkRequest request = QNetworkRequest(QUrl(sUrl));
    18. request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlenconded");
    19.  
    20. m_Manager->post(request, file.readAll());
    21.  
    22. file.close();
    23. }
    24.  
    25. void ClassX::onFinished(QNetworkReply *pReply)
    26. {
    27. pReply->close();
    28. pReply->deleteLater();
    29. }
    30.  
    31. // Look above at Main.cpp to see how this is called
    32. void ClassX::Finalize()
    33. {
    34. m_Manager->disconnect();
    35. delete m_Manager;
    36. m_Manager = NULL;
    37. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 16th November 2016 at 10:08. Reason: missing [code] tags

Similar Threads

  1. Again QNetworkAccessManager POST and PHP
    By ZSWASW in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2014, 19:38
  2. QNetworkAccessManager post
    By januszmk in forum Newbie
    Replies: 2
    Last Post: 13th April 2012, 09:01
  3. POST and QNetworkAccessManager
    By hakermania in forum Newbie
    Replies: 1
    Last Post: 13th February 2011, 00:05
  4. QNetworkAccessManager::post() never returns
    By danc81 in forum Qt Programming
    Replies: 2
    Last Post: 21st October 2009, 09:13
  5. QNetworkAccessManager double post
    By QPlace in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2009, 04:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.