VirtualBox

Changeset 63915 in vbox


Ignore:
Timestamp:
Sep 20, 2016 4:23:51 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
110795
Message:

FE/Qt: bugref:6899: Accessibility support (step 40): Selector UI: More appropriate workaround for Snapshot tree accessibility interface which feats the weird Qt5 tree-view logic (and allows to avoid fixing crash from Qt5 side).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp

    r63897 r63915  
    400400    AssertPtrReturn(tree(), 0);
    401401    /* Make sure index is valid: */
    402     // WORKAROUND:
    403     // Usually I would assert here, but Qt5 accessibility code has
    404     // a hard-coded architecture for a tree-views which we do not like
    405     // but have to live with and this architecture enumerates children
    406     // of all levels as children of level 0, so Qt5 can try to address
    407     // our interface with index which surely out of bounds by our laws.
    408     if (iIndex < 0 || iIndex >= childCount())
    409         return 0;
     402    AssertReturn(iIndex >= 0, 0);
     403    if (iIndex >= childCount())
     404    {
     405        // WORKAROUND:
     406        // Normally I would assert here, but Qt5 accessibility code has
     407        // a hard-coded architecture for a tree-views which we do not like
     408        // but have to live with and this architecture enumerates children
     409        // of all levels as children of level 0, so Qt5 can try to address
     410        // our interface with index which surely out of bounds by our laws.
     411        // So let's assume that's exactly such case and try to enumerate
     412        // visible children like they are a part of the list, not tree.
     413        // printf("Invalid index: %d\n", iIndex);
     414
     415        // Visible children indexes starts with 1, not 0,
     416        // don't ask me why, it's some stupid Qt5 idea:
     417        const int iRequiredIndex = iIndex - 1;
     418
     419        // Do some sanity check as well, enough?
     420        AssertReturn(iRequiredIndex >= 0, 0);
     421
     422        // Try to find a visible child with required index:
     423        int iCurrentIndex = 0;
     424        QTreeWidgetItem *pItem = tree()->topLevelItem(0);
     425        while (pItem && iCurrentIndex < iRequiredIndex)
     426        {
     427            ++iCurrentIndex;
     428            pItem = tree()->itemBelow(pItem);
     429        }
     430
     431        // Return what we found:
     432        // if (pItem)
     433        //     printf("Item found: [%s]\n", pItem->text(0).toUtf8().constData());
     434        return pItem ? QAccessible::queryAccessibleInterface(UISnapshotPane::toSnapshotItem(pItem)) : 0;
     435    }
    410436
    411437    /* Return the child with the passed iIndex: */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette