Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Stop download with QNetworkReply

    General and Desktop
    qnetworkreply
    4
    20
    4011
    Loading More Posts
    • 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.
    • A
      ARASHz4 last edited by

      i can't stop download with this code

      reply->abort();
      

      Download is stopped but still using network for download file!

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        Hi
        What you mean " still using network for download file"
        What if u completely close program. Is this usage then stopped?

        A 1 Reply Last reply Reply Quote 0
        • A
          ARASHz4 @mrjj last edited by

          @mrjj yes when completely close program usage stop

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @ARASHz4 last edited by

            @ARASHz4 said:
            ok. maybe silly questions but the QNetworkReply you abort() is
            the only active one?

            A 1 Reply Last reply Reply Quote 0
            • A
              ARASHz4 @mrjj last edited by ARASHz4

              @mrjj Sorry what you mean 'only active one' ?

              mrjj 1 Reply Last reply Reply Quote 0
              • mrjj
                mrjj Lifetime Qt Champion @ARASHz4 last edited by

                @ARASHz4
                Im just fishing.
                Is there any chance u abort other one
                than the actual download one?

                A 1 Reply Last reply Reply Quote 1
                • A
                  ARASHz4 @mrjj last edited by ARASHz4

                  @mrjj no i just have one download

                  mrjj 1 Reply Last reply Reply Quote 0
                  • mrjj
                    mrjj Lifetime Qt Champion @ARASHz4 last edited by

                    @ARASHz4
                    Ok. abort should do it as far as I know.
                    Sorry. lets wait and see if someone has better ideas.

                    A 1 Reply Last reply Reply Quote 0
                    • A
                      ARASHz4 @mrjj last edited by ARASHz4

                      @mrjj OK this is my Project if you can take look

                      mrjj 1 Reply Last reply Reply Quote 1
                      • mrjj
                        mrjj Lifetime Qt Champion @ARASHz4 last edited by

                        @ARASHz4
                        Thx. its cute :)
                        I can use any file for test?

                        A 1 Reply Last reply Reply Quote 0
                        • A
                          ARASHz4 @mrjj last edited by

                          @mrjj yes I think

                          ? mrjj 2 Replies Last reply Reply Quote 0
                          • ?
                            A Former User @ARASHz4 last edited by

                            Hi! Does this also happen when you replace abort() with close()? Another thing: After calling abort(), is the finished() signal emitted?

                            ? 1 Reply Last reply Reply Quote 0
                            • ?
                              A Former User @Guest last edited by

                              And: On what platform do you observe this behaviour? Windows? Linux?

                              A 1 Reply Last reply Reply Quote 0
                              • ?
                                A Former User last edited by

                                BTW: In your cancelDownload() function, it says:

                                reply->abort();
                                reply = 0;
                                

                                Looks like a memory leak to me.

                                1 Reply Last reply Reply Quote 0
                                • A
                                  ARASHz4 @Guest last edited by

                                  @Wieland
                                  i test before close()
                                  i use Windows now

                                  1 Reply Last reply Reply Quote 0
                                  • mrjj
                                    mrjj Lifetime Qt Champion @ARASHz4 last edited by

                                    @ARASHz4

                                    hi
                                    in

                                    Downloader::Downloader(QUrl Url, QObject *parent) :
                                        QObject(parent)
                                    {
                                        QNetworkRequest request(Url);
                                        DownloadManager.get(request);<<<<< THIS ?
                                    
                                        reply =  DownloadManager.get(request);
                                    

                                    you have extra DownloadManager.get(request);
                                    if I // it, it now drops to 0 when I abort.
                                    Before it did not.

                                    ? A 3 Replies Last reply Reply Quote 1
                                    • ?
                                      A Former User @mrjj last edited by

                                      @mrjj Guter Mann. ;-)

                                      1 Reply Last reply Reply Quote 1
                                      • A
                                        ARASHz4 @mrjj last edited by ARASHz4

                                        @mrjj DownloadManager is a private member in downloader.h

                                        1 Reply Last reply Reply Quote 0
                                        • A
                                          ARASHz4 @mrjj last edited by

                                          @mrjj Yes thank you now I understand
                                          i Fix it

                                          1 Reply Last reply Reply Quote 0
                                          • S
                                            seyed last edited by

                                            In my case, disconnecting all signals relating to QNetworkReply from all slots causes to abort() not works.

                                            disconnect(m_reply, nullptr, nullptr, nullptr);
                                            

                                            abort function works normal after commenting this line.

                                            1 Reply Last reply Reply Quote 2
                                            • First post
                                              Last post