Results 1 to 11 of 11

Thread: QTreeView: a few clicks crash

  1. #1
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default QTreeView: a few clicks crash

    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).
    click_place.png

    After doing that you get assertion failed.
    crash.png

    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).
    callstack_coordinateForItem.jpgcallstack_viewportEvent.jpg

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

    Here goes the complete application code.
    Qt Code:
    1. #include <QtCore>
    2. #include <QtGui>
    3.  
    4. int main(int argc, char ** argv)
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. QStandardItemModel dataModel;
    9.  
    10. // populate data model
    11. for (int i = 0; i < 5; ++i)
    12. {
    13. QList<QStandardItem *> primaryItems;
    14. primaryItems.append(new QStandardItem(QString("primary item %1").arg(i)));
    15. primaryItems.append(new QStandardItem("info"));
    16.  
    17. QStandardItem *dBranch = new QStandardItem("branch 1");
    18.  
    19. for (int f = 0; f < 10; ++f) // add sub-items to the branch 1
    20. {
    21. QList<QStandardItem*> subItems;
    22. subItems.append(new QStandardItem(QString("sub-item %1").arg(f)));
    23. subItems.append(new QStandardItem("sub-item info"));
    24.  
    25. dBranch->appendRow(subItems);
    26. }
    27.  
    28. primaryItems.first()->appendRow(dBranch);
    29.  
    30. dataModel.appendRow(primaryItems);
    31. } // over i
    32.  
    33. QTreeView treeView;
    34. treeView.setModel(&dataModel);
    35. treeView.setEditTriggers(QAbstractItemView::NoEditTriggers);
    36. treeView.header()->setResizeMode(QHeaderView::ResizeToContents);
    37. treeView.resize(300, 350);
    38. treeView.show();
    39.  
    40. return app.exec();
    41. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTreeView: a few clicks crash

    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 ?

  3. #3
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: QTreeView: a few clicks crash

    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.

  4. #4
    Join Date
    Feb 2011
    Posts
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeView: a few clicks crash

    I tested this and have the same issue (Vista x86)
    Here a video how to reproduce

  5. #5
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTreeView: a few clicks crash

    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.

  6. #6
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: QTreeView: a few clicks crash

    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.

  7. #7
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTreeView: a few clicks crash

    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 ?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeView: a few clicks crash

    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?"
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: QTreeView: a few clicks crash

    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.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeView: a few clicks crash

    Quote Originally Posted by mentalmushroom View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: QTreeView: a few clicks crash

    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.

Similar Threads

  1. Multiple clicks required to get into edit mode on QTreeView
    By JonInAnnArbor in forum Qt Programming
    Replies: 10
    Last Post: 26th November 2012, 18:59
  2. Simulate left and right clicks?
    By hakermania in forum Newbie
    Replies: 5
    Last Post: 8th June 2011, 11:44
  3. Replies: 2
    Last Post: 20th December 2010, 17:51
  4. Replies: 3
    Last Post: 12th May 2010, 13:11
  5. Weird crash caused by a QTreeView
    By vfernandez in forum Qt Programming
    Replies: 1
    Last Post: 10th September 2006, 18:31

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.