Results 1 to 3 of 3

Thread: QNetworkAccessManager used by QTimer causes falling

  1. #1
    Join Date
    Dec 2015
    Posts
    6
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QNetworkAccessManager used by QTimer causes falling

    I am using QNetworkAccessManager in function, which is run periodically by QTimer. The code is:
    Qt Code:
    1. QTimer* timer=new QTimer(this);
    2. connect(timer, SIGNAL(timeout()), this, SLOT(findUpdate()));
    3. timer->setSingleShot(false);
    4. timer->start(frequency*1800000);
    5.  
    6. void MainWindow::findUpdate()
    7. {
    8. for (int i=0;i<aplikace.count();i++){
    9. QNetworkAccessManager* manager=new QNetworkAccessManager(this);
    10. connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(checkUpdate(QNetworkReply*)));
    11. manager->get(QNetworkRequest(QUrl("http://www.gibucsoft.8u.cz/"+lang+"gibuclauncher/verze.php?ver="+aplikace.at(i))));
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 
    The compilation is fine and when I run my application from the Qt Creator it is OK as well but when I run it from the OS the program falls after a while (but not long enough for the timer to even start the function findUpdate). Sometimes before falling this error message shows:
    This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

  2. #2
    Join Date
    Dec 2015
    Posts
    6
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QNetworkAccessManager used by QTimer causes falling

    I already know the solution, the error was in creating a new QNetworkAccessManager each time. When I use only one, the application seems to work fine. But strange is, that in previous versions of my application it worked with multiple instances as well.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QNetworkAccessManager used by QTimer causes falling

    Even a new QNetworkAccessManager should work, just very wasteful.

    In any case the primary way to debug a crash is to look at the stack trace at the time of crash.

    Cheers,
    _

Similar Threads

  1. QNetworkAccessManager, not using it right?
    By Cruz in forum Qt Programming
    Replies: 3
    Last Post: 24th November 2016, 15:48
  2. Example for QNetworkAccessManager with SSL
    By KeineAhnung in forum Newbie
    Replies: 1
    Last Post: 12th February 2016, 13:52
  3. How to use QNetworkAccessManager?
    By radmir in forum Newbie
    Replies: 1
    Last Post: 25th February 2013, 14:43
  4. Replies: 1
    Last Post: 25th October 2012, 19:47
  5. Replies: 15
    Last Post: 4th August 2012, 19:11

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.