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

When accessibility is in use, setting a QListView's model to null causes a crash

    XMLWordPrintable

Details

    Description

      I saw this on a Mac. I think it would also happen on Windows though.

      To reproduce:

      1. Turn on VoiceOver (I think any of the accessibility features would do actually, but this is what I used).
      2. Build and run the attached test app 'qt-list-view-accessibility'.
      3. Click on the button to clear the list view by setting the model to null.

      It will crash, and if you look at the application output console you'll see that before it did so there were some accessibility warnings:

      Cannot creat accessible child interface for object: QListView(0x101bae550, name = "listView") index: 1

      I think there are two problems here.

      The cause of the crash seems to be some muddled-up code in QAccessibleEvent::uniqueId(). It checks for a null interface, returning 0 for an id in that case, which seems to be OK, but if a child is set but the parent interface returns a null pointer for that child, it will still end up calling QAccessible::uniqueId(QAccessibleInterface *iface) with a null pointer, and this seems to assume that the pointer is valid.

      The wider problem is that the accessibility code for list views relies on there being a model, and so calling it when there is no model will fail to find the accessible interface correctly, as the warning reports. This never used to happen, but the fix for QTBUG-50535 added calls to selectionChanged and currentChanged in QAbstractItemView::setSelectionModel, which gets called in setModel(). The implementations of these methods in QListView call updateAccessibility(...) which results in the warnings you see in the console.

      I'm not quite sure what ideal fix is here - for now I've fixed the crash and have patched the code in QListView::selectionChanged() and QListView::currentChanged() to not do the accessibility stuff if the model() returns 0.

      Attachments

        Issue Links

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

          Activity

            People

              frederik Frederik Gladhorn
              jlarcombe James Larcombe
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes