Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-19114

Impossible to abort() XMLHttpRequest (because there is no way to refer to it)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.0.0
    • 4.7.3
    • None
    • MacOS X 10.6.7, Qt coming with the final SDK 1.1
    • 752cd2aca42f6625f1cfc364937e0d39828cf954

    Description

      This bug is really about that it's impossible to store certain kinds of objects as a QML property, but the particularly important consequence is that it's impossible to cancel the HTTP request from QML.

      XMLHttpRequest supported by QML has an abort() method that works perfectly when you access it from where you create the object. For example the following works:

      onClicked: {
                  console.log("wholeArea clicked")
                  var doc = new XMLHttpRequest();
                  doc.onreadystatechange = function() {
                      if(doc.readyState == XMLHttpRequest.DONE) {
                          console.log("conv: doc loaded fully: " + doc.responseText)
      
                      } else if (doc.readyState == XMLHttpRequest.LOADING) {
                          console.debug("conv: doc readyState changed to LOADING")
                          doc.abort()
                      } else {
                          console.debug("conv: doc readyState changed not to DONE or LOADING, but to " + doc.readyState);
                      }
                  }
      
                  doc.open("GET", "http://az.lib.ru/t/tolstoj_lew_nikolaewich/text_0040.shtml");
                  doc.send();
              }
      

      Unfortunately you almost never would want to do that. You may want to cancel the loading from some completely different place e.g. when the user taps the "Cancel" button. And, surprisingly, there is no way to refer to XMLHttpRequest out of its original javascript scope. It is impossible to make a javascript object be a QML property and if you use variant, you can't call the abort function, you'll get "TypeError: Result of expression 'request.abort' [undefined] is not a function." See the example file attached

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            chriadam Christopher Adams (closed Nokia identity) (Inactive)
            artem.marchenko Artem Marchenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes