Bug 303228 - KCategorizedView is calling visualRect recursively
Summary: KCategorizedView is calling visualRect recursively
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: kdeui (show other bugs)
Version: 4.8.4
Platform: Debian unstable Linux
: NOR critical
Target Milestone: ---
Assignee: Rafael Fernández López
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-09 09:33 UTC by Percy Camilo Triveño Aucahuasi
Modified: 2024-09-14 17:06 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
sample code of the test case (2.72 KB, text/x-c++src)
2012-07-12 07:46 UTC, Percy Camilo Triveño Aucahuasi
Details
crash backtrace of the test case (50.81 KB, text/plain)
2012-07-12 07:47 UTC, Percy Camilo Triveño Aucahuasi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Percy Camilo Triveño Aucahuasi 2012-07-09 09:33:56 UTC
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
Comment 1 Percy Camilo Triveño Aucahuasi 2012-07-12 07:46:31 UTC
Created attachment 72470 [details]
sample code of the test case
Comment 2 Percy Camilo Triveño Aucahuasi 2012-07-12 07:47:03 UTC
Created attachment 72471 [details]
crash backtrace of the test case
Comment 3 Percy Camilo Triveño Aucahuasi 2012-07-12 07:49:40 UTC
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 ---
Comment 4 Thomas Lübking 2012-07-12 19:58:09 UTC
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.
Comment 5 Christoph Cullmann 2024-09-14 17:06:42 UTC
Hi,

kdelibs (version 4 and earlier) is no longer maintained since a few years.

KDE Frameworks 5 or 6 might already have resolved this bug.

If not, please re-open against the matching framework if feasible or against the application that shows the issue.

We then can still dispatch it to the right Bugzilla product or component.

Greetings
Christoph Cullmann