PDA

View Full Version : QTreeView: a few clicks crash



mentalmushroom
26th January 2012, 10:32
Hello

I’ve noticed a strange thing happens with QTreeView. In order to demonstrate it I created a small application. The program has one and only window that is actually a QTreeView instance. This tree contains several rows, each row has a sub-branch, and inside the sub-branch there are several sub-items (see the first image attached).

To see what I mean run the app, expand the last item of the tree and its sub-branch, click the down arrow of the vertical scrollbar to scroll it a little bit down, then click 4 times quickly on the collapse/expand button (see the red circle on the image).
7321

After doing that you get assertion failed.
7324

Seems like QTreeView can’t find an item for the mouse position, because it moved when the branch was collapsed. I’ve attached two screenshots that show the stack state (perhaps, useful).
73227323

My question – is there any solution/workaround for that or should I report a bug?

Here goes the complete application code.


#include <QtCore>
#include <QtGui>

int main(int argc, char ** argv)
{
QApplication app(argc, argv);

QStandardItemModel dataModel;

// populate data model
for (int i = 0; i < 5; ++i)
{
QList<QStandardItem *> primaryItems;
primaryItems.append(new QStandardItem(QString("primary item %1").arg(i)));
primaryItems.append(new QStandardItem("info"));

QStandardItem *dBranch = new QStandardItem("branch 1");

for (int f = 0; f < 10; ++f) // add sub-items to the branch 1
{
QList<QStandardItem*> subItems;
subItems.append(new QStandardItem(QString("sub-item %1").arg(f)));
subItems.append(new QStandardItem("sub-item info"));

dBranch->appendRow(subItems);
}

primaryItems.first()->appendRow(dBranch);

dataModel.appendRow(primaryItems);
} // over i

QTreeView treeView;
treeView.setModel(&dataModel);
treeView.setEditTriggers(QAbstractItemView::NoEdit Triggers);
treeView.header()->setResizeMode(QHeaderView::ResizeToContents);
treeView.resize(300, 350);
treeView.show();

return app.exec();
}

stampede
27th January 2012, 00:44
Can't reproduce (tested on windows 7), I scroll down and click on it many times and nothing interesting happens. Do you have maybe another system to test it ? What Qt version are you using ?

mentalmushroom
27th January 2012, 08:04
I am using Windows 7 x64, Qt 4.7.2 + Visual Studio 2008 SP1. I've also tested it on another machine with Vista x86 - also crashed.

Perhaps, it somehow depends on hardware and speed of events processing, so it may happen more or less often on other machines. I noticed sometimes I had to wait a few seconds before it crashed. Sometimes it appeared only when I moved a mouse after clicking. I can try to make a video if needed.

Also I noticed it very rarely happens when you delete items, but this crash I don't know how to reproduce either.

janton
27th January 2012, 10:31
I tested this and have the same issue (Vista x86)
Here a video how to reproduce

http://www.youtube.com/watch?v=eCexNlONtJU

stampede
27th January 2012, 13:05
Don't know if this matter, but I have all the graphics effects disabled (aero composition etc, all is set to "best performance"). You may try with that setting too.

mentalmushroom
27th January 2012, 14:00
I tried to turn off Aero and it seems like it doesn't affect the crash. The crash still happens and it is pretty simple to make it to appear. If you can't reproduce it make sure you do exactly the same. Expand the last row (and sub-branch), not something else. Don't scroll totally down - do only one click on the scrollbar down arrow. When you are clicking it needs to be done VERY QUICKLY. When you finish clicking you should get the mouse positioned on the "primary item 4". Then move a mouse and the crash should appear.

I didn't try it with the newer versions of Qt, but there is high chance it was not fixed there. I hope the issue will be addressed and resolved.

stampede
27th January 2012, 14:44
I see that both of you are using Visual Studio, I'm using mingw (gcc 4.5.2). Can you try that ? Can anyone using mingw verify this crash ?

wysota
27th January 2012, 15:37
Did anyone check what is contained in the line reported by Visual Studio or are you just limiting yourself to "hey, my app crashed, is it a bug in Qt?"

mentalmushroom
27th January 2012, 19:23
I see that both of you are using Visual Studio, I'm using mingw (gcc 4.5.2). Can you try that ? Can anyone using mingw verify this crash ?
I've never used mingw, so I am afraid I can't help with that. Perhaps, somebody else can.


Did anyone check what is contained in the line reported by Visual Studio or are you just limiting yourself to "hey, my app crashed, is it a bug in Qt?"
What should I check? That was a qt code. I don't understand it really well, but as far as I understood it can't find an item at the mouse position, because it was moved when the branch was collapsed and scrollbar disappeared.

wysota
27th January 2012, 19:58
What should I check? That was a qt code.
So have a look at it. And see why Qt aborted your app.


I don't understand it really well, but as far as I understood it can't find an item at the mouse position, because it was moved when the branch was collapsed and scrollbar disappeared.
Code aborts at an assert which means two things. One is that there is a problem here somewhere you need to either address or work around, and two that if you build your app in release mode there is a good chance it won't crash.

mentalmushroom
28th January 2012, 08:09
You are right, in release mode it doesn't crash (at least I could not make it to appear). But still failed assertion is a little bit "boo".
On Mac OS X Lion 10.7.1 + Qt 4.7.4 (Qt Creator) it doesn't crash in debug mode either.