Results 1 to 3 of 3

Thread: Libcurl messes up the order of execution

  1. #1
    Join Date
    Sep 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Libcurl messes up the order of execution

    Hello,

    I have a program that downloads some XML files off the web and i used QT to implement a minimalistic GUI for it. For the transfer part i decided to use libcurl, since i just began programming with QT and didn't knew about QHttp and i used libcurl in the past for http transfers.

    Whilst implementing a progress bar i ran into some problems, that are apparently caused by libcurl. I wanted to display the progress bar widget and then start downloading the XML files, but it happened the other way around. That is libcurl started to download the file and the progress bar appeared only after the files were downloaded. I managed to replicate the same problem with a small project and attached it here.

    I will eventually switch to QHttp since it's simpler to use and suits my problem just fine, but i'm dying of curiosity as to why this happens.
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Libcurl messes up the order of execution

    Most likely this happens because the main thread gets blocked by downloading the file and doesn't have enough time to handle the events in the eventloop.
    Therefor, the actual displaying of the widget and/or updating of the statusbar happens when the eventloop gets enough time.

    How to work around this:
    1. Use asynchronous sockets, this means a socket that doesn't block the event loop but instead makes use of the event loop
    2. Put all the downloading into a separate thread.

  3. #3
    Join Date
    Sep 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Libcurl messes up the order of execution

    Thank you very much for your suggestions. I had a hunch that using a separate thread for downloading will be the solution to my problem but i was unsure and i just wanted to keep things sequential.

Similar Threads

  1. using libcurl in QT with Mingw in Windows
    By ct in forum Qt Programming
    Replies: 18
    Last Post: 23rd January 2012, 01:41
  2. Execution order
    By Ishtar in forum Newbie
    Replies: 2
    Last Post: 26th April 2010, 20:36
  3. Lib not found in execution.
    By Netich in forum Installation and Deployment
    Replies: 6
    Last Post: 30th October 2009, 14:28
  4. execution in QT
    By adamatic in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2009, 08:12
  5. execution of slots
    By smalls in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2006, 19:38

Tags for this Thread

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.