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

Crash while attempting to load rich text resource from an invalid scheme

    XMLWordPrintable

Details

    • 8a0787f3b (dev), 21dbb7800 (6.7)

    Description

      import QtQuick
      
      TextEdit {
          textDocument.source: "unsupportedResourceScheme.md"
      }
      
      # Images that you can't load
      
      ![alt text](gopher://qt.io/icon48.png "some sort of fictitious icon")
      
      ![alt text](gopher://qt.io/icon24.png "another to attempt loading in parallel")
      

      gopher is a protocol that we have never supported (and perhaps unsuitable for images anyway? not sure) so it will always fail; but you could substitute ftp (not currently supported) or even https if something is wrong with your ssl setup (as reported initially).

      The problem is with one thread deleting a QQuickPixmap because the load job failed, while another thread still sees it in pixmapsInProgress:

      void QQuickTextEdit::resourceRequestFinished()
      {
          Q_D(QQuickTextEdit);
          bool allDone = true;
          for (auto it = d->pixmapsInProgress.cbegin(); it != d->pixmapsInProgress.cend();) {
              auto *job = *it;
              if (job->isError()) { // <-----
                  // get QTextDocument::loadResource() to call QQuickTextEdit::loadResource() again, to return the placeholder
                  qCDebug(lcTextEdit) << "failed to load" << job->url();
                  d->document->resource(QTextDocument::ImageResource, job->url());
              } else if (job->isReady()) {
                  // get QTextDocument::loadResource() to call QQuickTextEdit::loadResource() again, and cache the result
                  auto res = d->document->resource(QTextDocument::ImageResource, job->url());
                  // If QTextDocument::resource() returned a valid variant, it's been cached too. Either way, the job is done.
                  qCDebug(lcTextEdit) << (res.isValid() ? "done downloading" : "failed to load") << job->url() << job->rect();
                  delete *it;  // <------
                  it = d->pixmapsInProgress.erase(it);
              } else {
      

      Attachments

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

        Activity

          People

            srutledg Shawn Rutledge
            srutledg Shawn Rutledge
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes