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. How to make version checking success?
Forum Updated to NodeBB v4.3 + New Features

How to make version checking success?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 254 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.
  • P Offline
    P Offline
    pachisuro4096
    wrote on last edited by
    #1

    Hi, I was sharing my application to users from Internet.
    I wonder how many times that people used my app.
    So I make a new url by url-shorter : reurl.cc , and put it in my code.
    When people launch my app, my app will first visit the url to get html then parse the version number in the html content.
    Therefore, I can get the visit number by reurl.cc service.

    But the truth is, it failed.
    I has about 4500 download times, but the visit number only few hundreds.
    I don't know which one is the reason:
    1.My app not even launch success, so version checking also failed.
    2.My version checking code has problem.
    3.Other reasons.

    Here is my checking codes:

    void CheckVersionThread::run(){
        QNetworkAccessManager manager;
        QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("https://reurl.cc/xxxxxxxxxxxxxxx")));
    
        QEventLoop event_loop;
        QObject::connect(reply , SIGNAL(finished()),
                &event_loop, SLOT(quit()));
        QTimer::singleShot(2000, reply, SLOT(abort()));
    
        event_loop.exec();
    
        QString htmlString{reply->readAll()};
    
        reply->close();
        reply->deleteLater();
        manager.deleteLater();
    
    //parse  html text content. in htmlString .......................
    //skip...........
    }
    

    Any suggestion for me?
    Thank you for your reading.

    J.HilkJ 1 Reply Last reply
    0
    • P pachisuro4096

      Hi, I was sharing my application to users from Internet.
      I wonder how many times that people used my app.
      So I make a new url by url-shorter : reurl.cc , and put it in my code.
      When people launch my app, my app will first visit the url to get html then parse the version number in the html content.
      Therefore, I can get the visit number by reurl.cc service.

      But the truth is, it failed.
      I has about 4500 download times, but the visit number only few hundreds.
      I don't know which one is the reason:
      1.My app not even launch success, so version checking also failed.
      2.My version checking code has problem.
      3.Other reasons.

      Here is my checking codes:

      void CheckVersionThread::run(){
          QNetworkAccessManager manager;
          QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("https://reurl.cc/xxxxxxxxxxxxxxx")));
      
          QEventLoop event_loop;
          QObject::connect(reply , SIGNAL(finished()),
                  &event_loop, SLOT(quit()));
          QTimer::singleShot(2000, reply, SLOT(abort()));
      
          event_loop.exec();
      
          QString htmlString{reply->readAll()};
      
          reply->close();
          reply->deleteLater();
          manager.deleteLater();
      
      //parse  html text content. in htmlString .......................
      //skip...........
      }
      

      Any suggestion for me?
      Thank you for your reading.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @pachisuro4096
      oh my goodness where to begin.

      • Using threads when not needed (asynchronous api)
      • forcing synchronous behaviour on asynch api
      • overwriting run as threading method
      • not using the exec() of QThread class but using an additional QEventloop
      • calling deleteLater on a stack variable

      the problem is probably your timeout 2 seconds could be to short


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      4

      • Login

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