Commit 08325ba3 authored by Thomas Lübking's avatar Thomas Lübking
Browse files

fix KCategorizedView race

BUG: 213068
BUG: 287847
REVIEW: 103335

QListView::updateGeometries() has it's own opinion on whether the scrollbars should be visible (valid range) or not
and triggers a (sometimes additionally timered) resize through ::layoutChildren()
http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/itemviews/qlistview.cpp#line1499
(the comment above the main block isn't all accurate, layoutChldren is called regardless of the policy)

As a result QListView and KCategorizedView occasionally started a race on the scrollbar visibility, effectively blocking the UI
So we prevent QListView from having an own opinion on the scrollbar visibility by
fixing it before calling the baseclass QListView::updateGeometries() and restoring the policy afterwards
parent c06e16ff
......@@ -492,7 +492,6 @@ void KCategorizedView::Private::topToBottomVisualRect(const QModelIndex &index,
QModelIndex prevIndex = proxyModel->index(index.row() - 1, q->modelColumn(), q->rootIndex());
QRect prevRect = q->visualRect(prevIndex);
prevRect = mapFromViewport(prevRect);
const QSize currSize = q->sizeHintForIndex(index);
item.topLeft.rx() = blockPos.x() + categoryDrawer->leftMargin() + q->spacing();
item.topLeft.ry() = (prevRect.bottomRight().y() + 1) + q->spacing() - blockPos.y();
} else {
......@@ -1354,8 +1353,29 @@ void KCategorizedView::updateGeometries()
{
const int oldVerticalOffset = verticalOffset();
//BEGIN bugs 213068, 287847 ------------------------------------------------------------
/*
* QListView::updateGeometries() has it's own opinion on whether the scrollbars should be visible (valid range) or not
* and triggers a (sometimes additionally timered) resize through ::layoutChildren()
* http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/itemviews/qlistview.cpp#line1499
* (the comment above the main block isn't all accurate, layoutChldren is called regardless of the policy)
*
* As a result QListView and KCategorizedView occasionally started a race on the scrollbar visibility, effectively blocking the UI
* So we prevent QListView from having an own opinion on the scrollbar visibility by
* fixing it before calling the baseclass QListView::updateGeometries() and restoring the policy afterwards
*/
const Qt::ScrollBarPolicy verticalP = verticalScrollBarPolicy(), horizontalP = horizontalScrollBarPolicy();
setVerticalScrollBarPolicy(verticalScrollBar()->isVisibleTo(this) ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(horizontalScrollBar()->isVisibleTo(this) ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
//END bugs 213068, 287847 --------------------------------------------------------------
QListView::updateGeometries();
//BEGIN bugs 213068, 287847 ------------------------------------------------------------
setVerticalScrollBarPolicy(verticalP);
setHorizontalScrollBarPolicy(horizontalP);
//END bugs 213068, 287847 --------------------------------------------------------------
if (!d->isCategorized()) {
return;
}
......@@ -1363,6 +1383,8 @@ void KCategorizedView::updateGeometries()
const int rowCount = d->proxyModel->rowCount();
if (!rowCount) {
verticalScrollBar()->setRange(0, 0);
// unconditional, see function end todo
horizontalScrollBar()->setRange(0, 0);
return;
}
......
......@@ -257,8 +257,6 @@ KPluginSelector::KPluginSelector(QWidget *parent)
d->lineEdit->setClickMessage(i18n("Search Plugins"));
d->listView = new KCategorizedView(this);
d->listView->setVerticalScrollMode(QListView::ScrollPerPixel);
d->listView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); // bug 213068
d->listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // bug 213068
d->listView->setAlternatingRowColors(true);
d->listView->setCategoryDrawer(d->categoryDrawer);
d->dependenciesWidget = new Private::DependenciesWidget(this);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment