Hi there, I modified the test of kcategorizedview to categorized the items in 2 groups: even/odd number, but kcategorizedview seem calling visualRect recursively ... ¿is this ok? or I'm doing something wrong? http://paste.kde.org/514292/ it seems the problem is arround line 25, this is the backtrace: http://paste.kde.org/514298/ Cheers, Percy Reproducible: Always Steps to Reproduce: 1.copy the paste 2.build debug mode Actual Results: visualRect() is calling itself recursively Expected Results: The view should show the items in two categories: odd and even
Created attachment 72470 [details] sample code of the test case
Created attachment 72471 [details] crash backtrace of the test case
Also you can use this use case: Is the same of the kdelibs/kdeui/test but this time we add more items after the view has been setup, please also note the comments about setCategorizedModel; so here is *another use case*: -- CUT FROM HERE --- #include <QMainWindow> #include <QStringListModel> #include <kapplication.h> #include <kaboutdata.h> #include <kcmdlineargs.h> #include <kiconloader.h> #include <kcategorizedview.h> #include <kcategorydrawer.h> #include <kcategorizedsortfilterproxymodel.h> QStringList icons; class MyModel : public QStringListModel { public: virtual QVariant data(const QModelIndex &index, int role) const { switch (role) { case KCategorizedSortFilterProxyModel::CategoryDisplayRole: { return QString::number(index.row() / 10); } case KCategorizedSortFilterProxyModel::CategorySortRole: { return index.row() / 10; } case Qt::DecorationRole: return DesktopIcon(icons[index.row() % 4], KIconLoader::Desktop); default: break; } return QStringListModel::data(index, role); } }; int main(int argc, char **argv) { icons << "konqueror"; icons << "okular"; icons << "plasma"; icons << "system-file-manager"; KAboutData aboutData("KCategorizedViewTest", 0, ki18n("KCategorizedViewTest"), "1.0", ki18n("KCategorizedViewTest"), KAboutData::License_LGPL_V3, ki18n("(c) 2009 Rafael Fernández López"), ki18n("KCategorizedViewTest"), "http://www.kde.org"); KCmdLineArgs::init(argc, argv, &aboutData); KApplication app; QMainWindow *mainWindow = new QMainWindow(); mainWindow->setMinimumSize(640, 480); KCategorizedView *listView = new KCategorizedView(); listView->setCategoryDrawer(new KCategoryDrawer()); listView->setViewMode(QListView::IconMode); MyModel *model = new MyModel(); model->insertRows(0, 100); for (int i = 0; i < 100; ++i) { model->setData(model->index(i, 0), QString::number(i), Qt::DisplayRole); } KCategorizedSortFilterProxyModel *proxyModel = new KCategorizedSortFilterProxyModel(); proxyModel->setCategorizedModel(true); proxyModel->setSourceModel(model); listView->setModel(proxyModel); //NOTE if you disable temporally the CategorizedModel flag work ok but the scroll bar fails //proxyModel->setCategorizedModel(false); //BEGIN HERE model->insertRows(0, 100); for (int i = 0; i < 100; ++i) { QModelIndex mi = model->index(0,0); model->setData(model->index(i, 0, mi), QString::number(i), Qt::DisplayRole); } //END HERE //NOTE if you reenabled the flag works fien but the scroll bar fails //proxyModel->setCategorizedModel(true); mainWindow->setCentralWidget(listView); mainWindow->show(); return app.exec(); } --- UNTIL HERE ---
Gave it a short test: case KCategorizedSortFilterProxyModel::CategorySortRole seems never be queried and the proxymodel most likely runs into a race on the items (ie. with i<2 everything is fine since there're only two non equal items and so is if you pass QString::number(index.role()) as display role. Don't ask me why, i got the nature of the bug wrong and then looked out of curiosity. I've never touched or seen the kcat'model code. Sorry.