Results 1 to 3 of 3

Thread: Segfault using QSortFilterProxeModel and QTreeView

  1. #1
    Join Date
    Oct 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation Segfault using QSortFilterProxeModel and QTreeView

    Hello there,

    I am using TreeItem and TreeModel classes from Qt SimpleTreeModel example, except for one method that is called constantly at rate of one per second:
    Qt Code:
    1. void TreeModel::addItem()
    2. {
    3. TreeItem* treeItem = new TreeItem;
    4. rootItem->appendChild(treeItem);
    5.  
    6. emit layoutChanged();
    7. }
    To copy to clipboard, switch view to plain text mode 
    As well I am using QSortFilterProxyModel following way:
    Qt Code:
    1. model = new TreeModel;
    2.  
    3. proxyModel = new QSortFilterProxyModel;
    4. proxyModel->setSourceModel(model);
    5. proxyModel->setDynamicSortFilter(true);
    6.  
    7. treeView = new QTreeView;
    8. treeView->setModel(proxyModel);
    To copy to clipboard, switch view to plain text mode 
    I have a stupid segfault and really need some help. Part of backtrace is below:
    Program received signal EXC_BAD_ACCESS, Could not access memory.
    Reason: 13 at address: 0x0000000000000000
    0x000000000000000a in QSortFilterProxyModelPrivate:: proxy_to_source ()
    (gdb) bt
    #0 0x000000000000000a in QSortFilterProxyModelPrivate:: proxy_to_source ()
    #1 0x000000000000000b in QSortFilterProxyModel::mapToSource ()
    Don't know will it help or no, but segfault repeats almost always after switching from fullscreen to normal.

    Where is the problem (imo, it is after layoutChanged() signal is emitted) and how can I fix it?

    I've read almost the whole Google and found some relative problems where it was advised to reimplement mapToSource() and mapFromSource(). But I can't make it right due to lack of skills.

    Really looking forward for your help. Big thanks in advance!

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Segfault using QSortFilterProxeModel and QTreeView

    Would it be an idea to properly use beginInsertRows() and endInsertRows() instead of emitting a custom layoutChanged() signal? Maybe that causes the issue in the first place.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Oct 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Red face Re: Segfault using QSortFilterProxeModel and QTreeView

    Quote Originally Posted by franz View Post
    Would it be an idea to properly use beginInsertRows() and endInsertRows() instead of emitting a custom layoutChanged() signal? Maybe that causes the issue in the first place.
    Thank you soo much! You can't even imagine, how have you helped me!
    The working code for now is below:
    Qt Code:
    1. void TreeModel::addItem()
    2. {
    3. TreeItem* treeItem = new TreeItem;
    4. beginInsertRows(QModelIndex(), rootItem->childCount(), rootItem->childCount());
    5. rootItem->appendChild(treeItem);
    6. endInsertRows();
    7. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Segfault openGL
    By qtnewb in forum Qt Programming
    Replies: 1
    Last Post: 27th November 2010, 11:32
  2. QwtPlotMarker segfault
    By viridis in forum Qwt
    Replies: 4
    Last Post: 17th September 2008, 13:22
  3. Segfault
    By Dumbledore in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2007, 07:31
  4. segfault
    By conexion2000 in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2006, 12:34
  5. segfault in qtfontdatabase_x11.cpp
    By e8johan in forum Installation and Deployment
    Replies: 3
    Last Post: 18th April 2006, 07:07

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
  •  
Qt is a trademark of The Qt Company.