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

QTableView::sizeHintForColumn() performance killer

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3: Somewhat important
    • 5.2.0
    • 4.5.2
    • Widgets: Itemviews
    • None
    • Linux

    Description

      NOTE, I checked v4.7.0-beta1's code in GIT and I believe the problem still exists.

      In sizeHintForColumn() there are these rows:

      int bottom = rowAt(d->viewport->height());
      if (!isVisible() || bottom == -1) // the table don't have enough rows to fill the viewport
      bottom = d->model->rowCount(d->root) - 1;

      I have a large table, so I want to ensure it only considers 300 rows or so, not the whole table.
      This is normally the case, however when shutting down my program, I get the following backtrace (shortened for brevity):

      #0 QTableView::sizeHintForColumn (this=0xa9b00710, column=10) at itemviews/qtableview.cpp:1561
      #1 0xb434d023 in QHeaderViewPrivate::viewSectionSizeHint (this=0xa9b043e8, logical=10)
      at itemviews/qheaderview.cpp:3477
      #2 0xb43522f5 in QHeaderViewPrivate::resizeSections (this=0xa9b043e8,
      globalMode=QHeaderView::Interactive, useGlobalMode=false) at itemviews/qheaderview.cpp:2983
      #3 0xb435266a in QHeaderView::resizeSections (this=0xa9b043d0) at itemviews/qheaderview.cpp:1614
      #4 0xb4355dcb in QHeaderView::viewportEvent (this=0xa9b043d0, e=0xbf9cde54)
      at itemviews/qheaderview.cpp:2389
      #5 0xb4271380 in QAbstractScrollAreaPrivate::viewportEvent (this=0xa9b043e8, event=0xbf9cde54)
      at widgets/qabstractscrollarea_p.h:100

      snip

      #13 0xb3d1f363 in QWidgetPrivate::hideChildren (this=0xa9b00798, spontaneous=false)
      at kernel/qwidget.cpp:7079

      snip

      #19 0xb423bcfc in QStackedWidget::removeWidget (this=0x8a25980, widget=0xa9b00710)
      at widgets/qstackedwidget.cpp:197

      Note that I am removing a widget, which hides it first, BUT triggers the resize code. Of course, when it checks isVisible(), its false, so sizeHintForColumn() ends up trying to check ALL of the rows for the sizehint... so my program can take 2 minutes to close when it should take seconds!

      How do I work around this?

      I could hack the code directly, but I'd rather not.
      Its not a virtual function, so I can't inherit and override.
      I could unset the model just before I close the program, but thats a lot of extra code on my end that I really shouldn't need to do.

      So I guess I have to hack/patch QT directly...

      Attachments

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

        Activity

          People

            tmartsum Thorbjørn Lund Martsum
            elegant_dice Paul
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes