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

Don't emit signals when clearing selection and signals are blocked

    XMLWordPrintable

Details

    Description

      Currently in my project (http://nano.yandex.ru/project/online/) I
      employ a pretty harsh way of using a model.

      When QSortFilterProxyModel in Qt 4.3 re-sorts
      everything every time it is very processor-hungry. So I have
      implement some hacks in order to boost performance, like after big
      updates I either do reset() + layoutAboutToBeChanged() +
      layoutChanged(), or layoutAboutToBeChanged() + layoutChanged(), and it
      could lead to very bad stuff happening.

      One of the crashes I've got because after I try to clear
      QItemSelectionModel it tries to gather some data in order to send a
      proper selectionChanged() signal. I then tried to work-around this by
      blocking signals altogether, but it didn't work because it still uses
      now-incorrect QModelIndexes at the data-gathering period, so I
      produced this patch:

      diff -urN qt-x11-opensource-src-4.3.5.orig/src/gui/itemviews/qitemselectionmodel.cpp qt-x11-opensource-src-4.3.5/src/gui/itemviews/qitemselectionmodel.cpp
      — qt-x11-opensource-src-4.3.5.orig/src/gui/itemviews/qitemselectionmodel.cpp 2008-09-02 16:12:14.000000000 +0400
      +++ qt-x11-opensource-src-4.3.5/src/gui/itemviews/qitemselectionmodel.cpp 2008-09-02 18:08:15.000000000 +0400
      @@ -1058,10 +1058,14 @@
      if (d->ranges.count() == 0 && d->currentSelection.count() == 0)
      return;
      QItemSelection selection = d->ranges;

      • selection.merge(d->currentSelection, d->currentCommand);
        + if (!signalsBlocked()) { + selection.merge(d->currentSelection, d->currentCommand); + }

        d->ranges.clear();
        d->currentSelection.clear();

      • emit selectionChanged(QItemSelection(), selection);
        + if (!signalsBlocked()) { + emit selectionChanged(QItemSelection(), selection); + }

        }

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            janichol Andy Nichols
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes