Results 1 to 20 of 21

Thread: Simplest app with QNetworkAccessManager and First-chance exception

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Simplest app with QNetworkAccessManager and First-chance exception

    Since the very beginning I was suspecting some problem with threads which could explain what is going on. However you said the code you posted was a complete testbed so the only threads running are those related to QNetworkAccessManager. Or at least that should be the case. On the other hand we can see around 10 threads in your app. Where are they coming from? Are you sure there is no additional code involved? Are you linking with some external libraries or something like that? Where does qmyapp.h come from?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Jan 2013
    Posts
    11
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default Re: Simplest app with QNetworkAccessManager and First-chance exception

    Quote Originally Posted by wysota View Post
    On the other hand we can see around 10 threads in your app. Where are they coming from?
    I wonder myself...

    Quote Originally Posted by wysota View Post
    Are you sure there is no additional code involved? Are you linking with some external libraries or something like that? Where does qmyapp.h come from?
    Yes, I'm sure. qmyapp.h - it contained custom QApplication derived class, but now I don't use it. I even removed it from the project - nothing changed.
    Input libraries: qtmaind.lib;QtCored4.lib;QtGuid4.lib;QtNetworkd4.l ib;

    OK, thank you anyway!

  3. #3
    Join Date
    Aug 2013
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Simplest app with QNetworkAccessManager and First-chance exception

    Did you solve this? I am running into the exact same problem in my code. Same stacktrace, same simple code, just a get() call with the QNAM. And its 100% reproducible.

  4. #4
    Join Date
    Aug 2013
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Simplest app with QNetworkAccessManager and First-chance exception

    I get this error as well, without even using the QNAM. It's loading 'qnativewifibearerd' and then crapping out in it after it tries to to call 'closeHandle'.
    My stack trace looks nearly the same.

    --chris

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Simplest app with QNetworkAccessManager and First-chance exception

    @pke: Are you using exactly the posted code without the customised QApplication, VS2010, and Qt 5.0.0? If so, upgrade your Qt and do a clean build.

    @crioux: So you are crashing in this fashion with a program that contains nothing except a QApplication instantiation and Designer Ui. Forgive me if I do not trust that assertion. Do a complete rebuild. Post a single file example and complete version details if the problem persists.

  6. #6
    Join Date
    Jul 2013
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Unhappy Re: Simplest app with QNetworkAccessManager and First-chance exception

    I have the same issue, QNetworkAccessManager cause a debug output like :
    test.exe .. 0x74fcb727 .....: 0x0000000D: The data is invalid


    my test environment is :

    window 7 64 bit
    visual studio 2008
    Qt 5.1

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Simplest app with QNetworkAccessManager and First-chance exception

    Quote Originally Posted by abc100m View Post
    I have the same issue,
    How do you know it is the same issue?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Jul 2013
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Simplest app with QNetworkAccessManager and First-chance exception

    I want to reproduce this issue, but same character is Chinese.

    Ok, I change a bit code that provide by #1. I create a new Qt project, and have two button:

    void Test::Request_finished(QNetworkReply *reply)
    {
    //reply->deleteLater();
    }

    void Test::Button_clicked()
    {
    manager = new QNetworkAccessManager(this);

    QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(Request_finished(QNetworkReply *)));
    QNetworkRequest request(QUrl("http://www.google.com"));
    reply = manager->get(request);
    }

    void Test::destroy_clicked()
    {
    qDebug() << "to delete reply...";
    if (reply)
    {
    reply->abort();
    delete reply;//->deleteLater();
    reply = NULL;
    }

    qDebug() << "to delete manager...";
    if (manager)
    {
    delete manager;
    manager = NULL;
    }

    qDebug() << "reply, manager destroyed...";
    }

    now, I begin to debug my test program in visual studio IDE(just F5).

    after the program is run, I break it to see how many threads, and now just have 6 threads:
    --------
    0 > 3012 主线程 主线程 _free_base æ*£å¸¸ 0
    0 1228 RPC 线程 RPC 回调线程 7739fd81 æ*£å¸¸ 0
    0 6636 辅助线程 Win32 线程 773a014d æ*£å¸¸ 0
    0 5628 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    0 5948 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    0 6696 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    ------------------

    now I click button1 to execute void Test::Button_clicked(), after executed I see there 14 threads:
    ---------------------
    0 > 3012 主线程 主线程 _free_base æ*£å¸¸ 0
    0 1228 RPC 线程 RPC 回调线程 7739f8c1 æ*£å¸¸ 0
    0 5928 辅助线程 Win32 线程 7739f8c1 æ*£å¸¸ 0
    0 7972 辅助线程 Win32 线程 7739f949 高于æ*£å¸¸ 0
    0 5632 辅助线程 Win32 线程 773a014d 时间关键 0
    0 6636 辅助线程 Win32 线程 773a014d æ*£å¸¸ 0
    0 4404 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    0 5528 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    0 5628 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    0 6260 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    0 6696 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    0 6640 辅助线程 Qt HTTP thread QMetaObject::activate æ*£å¸¸ 0
    0 8092 辅助线程 Qt bearer thread QMetaObject::activate æ*£å¸¸ 0
    0 4496 辅助线程 Thread (pooled) QWaitConditionPrivate::wait æ*£å¸¸ 0
    ---------------------

    and these time I click button2 to execute void Test::destroy_clicked(), after execute I see there 10 threads left:
    ---------------------
    0 > 3012 主线程 主线程 _free_base æ*£å¸¸ 0
    0 5928 辅助线程 Win32 线程 7739f8c1 æ*£å¸¸ 0
    0 5632 辅助线程 Win32 线程 773a014d 时间关键 0
    0 6636 辅助线程 Win32 线程 773a014d æ*£å¸¸ 0
    0 3092 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    0 4060 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    0 5528 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    0 5628 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
    0 4912 辅助线程 qt_adopted_thread_watcher_function QArrayData::data æ*£å¸¸ 0
    0 8092 辅助线程 Qt bearer thread QMetaObject::activate æ*£å¸¸ 0
    ---------------------------

    after about 1 minute, I close the test program, and the visual studio debug window shows:
    --------------------------
    to delete reply...
    to delete manager...
    线程 'Qt HTTP thread' (0x19f0) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    reply, manager destroyed...
    线程 'Win32 线程' (0xc14) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    线程 'Win32 线程' (0x15fc) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    test.exe ä¸*çš„ 0x74fcb727 处最可能的异常: 0x0000000D: The data is invalid
    线程 'Win32 线程' (0x1728) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    线程 'qt_adopted_thread_watcher_function' (0x1330) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    线程 'Qt bearer thread' (0x1f9c) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    线程 'Win32 线程' (0x1600) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    线程 'Win32 线程' (0x1338) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    线程 'Win32 线程' (0x1598) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    线程 'Win32 线程' (0xfdc) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    线程 'Win32 线程' (0x19ec) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    线程 'Win32 线程' (0xe9c) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
    程序“[4784] test.exe: æœ¬æœºâ€å·²é€€å‡ºï¼Œè¿ ”回值为 0 (0x0)。
    ------------------------------------------------

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Simplest app with QNetworkAccessManager and First-chance exception

    Your code goes way past an empty project with an instance of QNetworkAccessManager that does nothing.

    If your back trace is different than OP's then please start your own thread instead of hijacking this one.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Jul 2013
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Simplest app with QNetworkAccessManager and First-chance exception

    Different back trace but have the same result,

    For test this case, I create a new Visual Studio project, and my test code list below. May be someone can test this code

    Qt Code:
    1. //test.h
    2. #ifndef TEST_H
    3. #define TEST_H
    4.  
    5. #include <QtWidgets/QMainWindow>
    6. #include <QtNetwork>
    7. #include "ui_test.h"
    8.  
    9.  
    10. class Test : public QMainWindow
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. Test(QWidget *parent = 0);
    16. ~Test();
    17.  
    18. public slots:
    19. void Button_clicked();
    20. void destroy_clicked();
    21. void Request_finished(QNetworkReply *reply);
    22.  
    23. private:
    24. Ui::TestClass ui;
    25. QNetworkReply* reply;
    26. QNetworkAccessManager* manager;
    27. };
    28.  
    29. #endif // TEST_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //test.cpp
    2. #include "test.h"
    3. #include <QtWidgets>
    4.  
    5. Test::Test(QWidget *parent)
    6. : QMainWindow(parent)
    7. {
    8. ui.setupUi(this);
    9. QObject::connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(Button_clicked()));
    10. QObject::connect(ui.btn_destroy, SIGNAL(clicked()), this, SLOT(destroy_clicked()));
    11.  
    12. reply = NULL;
    13. manager = NULL;
    14. }
    15.  
    16. Test::~Test()
    17. {
    18. }
    19.  
    20. void Test::Request_finished(QNetworkReply *reply)
    21. {
    22. //reply->deleteLater();
    23. }
    24.  
    25. void Test::Button_clicked()
    26. {
    27. manager = new QNetworkAccessManager(this);
    28. QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(Request_finished(QNetworkReply *)));
    29. QNetworkRequest request(QUrl("http://www.google.com"));
    30. reply = manager->get(request);
    31. }
    32.  
    33. void Test::destroy_clicked()
    34. {
    35. qDebug() << "to delete reply...";
    36. if (reply)
    37. {
    38. reply->abort();
    39. delete reply;//->deleteLater();
    40. reply = NULL;
    41. }
    42.  
    43. qDebug() << "to delete manager...";
    44. if (manager)
    45. {
    46. delete manager;
    47. manager = NULL;
    48. }
    49.  
    50. qDebug() << "reply, manager destroyed...";
    51. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 5th September 2013 at 21:34. Reason: missing [code] tags

Similar Threads

  1. Simplest example for QGraphicsPixmapItem
    By sincnarf in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2012, 14:24
  2. Simplest SQL example
    By janus66 in forum Newbie
    Replies: 3
    Last Post: 21st July 2011, 07:40
  3. the simplest custom slot
    By tommy in forum Qt Programming
    Replies: 30
    Last Post: 12th November 2007, 11:18
  4. simplest / best way to fuse several files with QT?
    By Havard in forum Qt Programming
    Replies: 3
    Last Post: 18th June 2007, 10:06
  5. A simplest ListModel... no example :(
    By tomek in forum Newbie
    Replies: 5
    Last Post: 7th January 2006, 00:32

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
  •  
Qt is a trademark of The Qt Company.