Bug 171991

Summary: kwidgetitemdelegate crash when QSortFilterProxyModel unhides filtered items
Product: [Unmaintained] kdelibs Reporter: Stefan Böhmann <kde>
Component: kdeuiAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: compressor, ereslibre, finex, s.gabriel, smal.root, whyheelllooo
Priority: NOR    
Version: SVN   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: backtrace
simple demo application

Description Stefan Böhmann 2008-10-01 22:15:30 UTC
Version:            (using Devel)
Compiler:          gcc 4.3.1 
OS:                Linux
Installed from:    Compiled sources

When I try to use KWidgetItemDelegate together with a QSortFilterProxyModel and the filter unhides items KWidgetItemDelegate crash.

I thought it was a mistake in my one code but later I found that also (at least) KNewStuff has the same issue. So either I do the same thinks wrong then KNewStuff or I found a bug in KWidgetItemDelegate. 

How to Reproduce:
Open a KNewStuff dialog (I tried Plasma's "Get New Wallpaper" and KHangman's "Get Words in New Language") and type some letters into the search field. Then, after some items disappears, clear the search line -> crash.
Comment 1 Stefan Böhmann 2008-10-01 22:16:51 UTC
Created attachment 27646 [details]
backtrace
Comment 2 FiNeX 2008-10-01 23:50:58 UTC
Backtrace copied from comment #1:


Application: KHangMan (khangman), signal SIGSEGV
[Current thread is 0 (LWP 16506)]

Thread 2 (Thread 0xb43bdb90 (LWP 16710)):
#0  0xb7fdd424 in __kernel_vsyscall ()
#1  0xb6d20352 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib/i686/cmov/libpthread.so.0
#2  0xb6d8651c in QWaitCondition::wait () from /usr/lib/libQtCore.so.4
#3  0xb6d7b7c6 in ?? () from /usr/lib/libQtCore.so.4
#4  0xb6d8552e in ?? () from /usr/lib/libQtCore.so.4
#5  0xb6d1c4c0 in start_thread () from /lib/i686/cmov/libpthread.so.0
#6  0xb6b7a55e in clone () from /lib/i686/cmov/libc.so.6

Thread 1 (Thread 0xb604e740 (LWP 16506)):
[KCrash Handler]
#6  0x082e8433 in ?? ()
#7  0xb7dcf89f in KWidgetItemDelegatePool::findWidgets (this=0x837ee18, idx=@0xbfbf5d18, option=@0xbfbf5c3c, updateWidgets=KWidgetItemDelegatePool::UpdateWidgets)
    at /home/compiler/kde/src/KDE/kdelibs/kdeui/itemviews/kwidgetitemdelegatepool.cpp:119
#8  0xb7dce1ce in KWidgetItemDelegatePrivate::updateRowRange (this=0x83f43f8, parent=@0xbfbf5eb4, start=0, end=34, isRemoving=false)
    at /home/compiler/kde/src/KDE/kdelibs/kdeui/itemviews/kwidgetitemdelegate.cpp:116
#9  0xb7dce38e in KWidgetItemDelegatePrivate::_k_slotRowsInserted (this=0x83f43f8, parent=@0xbfbf5eb4, start=0, end=34)
    at /home/compiler/kde/src/KDE/kdelibs/kdeui/itemviews/kwidgetitemdelegate.cpp:70
#10 0xb7dce49f in KWidgetItemDelegate::qt_metacall (this=0x83f40f0, _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0xbfbf5e74) at /home/compiler/kde/build/KDE/kdelibs/kdeui/kwidgetitemdelegate.moc:73
#11 0xb702400a in KNS::ItemsViewDelegate::qt_metacall (this=0x83f40f0, _c=QMetaObject::InvokeMetaMethod, _id=9, _a=0xbfbf5e74)
    at /home/compiler/kde/build/KDE/kdelibs/knewstuff/knewstuff2/moc_itemsviewdelegate.cpp:69
#12 0xb6e89bd0 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#13 0xb6e8a952 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#14 0xb6ec3a5f in QAbstractItemModel::rowsInserted () from /usr/lib/libQtCore.so.4
#15 0xb6e705f3 in QAbstractItemModel::endInsertRows () from /usr/lib/libQtCore.so.4
#16 0xb76f3503 in ?? () from /usr/lib/libQtGui.so.4
#17 0xb76f87f4 in ?? () from /usr/lib/libQtGui.so.4
#18 0xb76f8973 in ?? () from /usr/lib/libQtGui.so.4
#19 0xb7050e9c in KNS::DownloadDialog::slotUpdateSearch (this=0x83e1db8) at /home/compiler/kde/src/KDE/kdelibs/knewstuff/knewstuff2/ui/downloaddialog.cpp:345
#20 0xb705631c in KNS::DownloadDialog::qt_metacall (this=0x83e1db8, _c=QMetaObject::InvokeMetaMethod, _id=8, _a=0xbfbf60f8)
    at /home/compiler/kde/build/KDE/kdelibs/knewstuff/knewstuff2/downloaddialog.moc:118
#21 0xb6e89bd0 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#22 0xb6e8a952 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#23 0xb6ec4857 in QTimer::timeout () from /usr/lib/libQtCore.so.4
#24 0xb6e9057e in QTimer::timerEvent () from /usr/lib/libQtCore.so.4
#25 0xb6e846af in QObject::event () from /usr/lib/libQtCore.so.4
#26 0xb71a8b3c in QApplicationPrivate::notify_helper () from /usr/lib/libQtGui.so.4
#27 0xb71b09be in QApplication::notify () from /usr/lib/libQtGui.so.4
#28 0xb7dded4d in KApplication::notify (this=0xbfbf78b0, receiver=0x83e1380, event=0xbfbf658c) at /home/compiler/kde/src/KDE/kdelibs/kdeui/kernel/kapplication.cpp:307
#29 0xb6e750d1 in QCoreApplication::notifyInternal () from /usr/lib/libQtCore.so.4
#30 0xb6ea3031 in ?? () from /usr/lib/libQtCore.so.4
#31 0xb6ea32cb in QEventDispatcherUNIX::processEvents () from /usr/lib/libQtCore.so.4
#32 0xb7243276 in ?? () from /usr/lib/libQtGui.so.4
#33 0xb6e7379a in QEventLoop::processEvents () from /usr/lib/libQtCore.so.4
#34 0xb6e7395a in QEventLoop::exec () from /usr/lib/libQtCore.so.4
#35 0xb706500e in KNS::EnginePrivate::workflow (this=0x83e6c60) at /home/compiler/kde/src/KDE/kdelibs/knewstuff/knewstuff2/engine.cpp:138
#36 0xb70651fc in KNS::Engine::downloadDialogModal (this=0x8328540) at /home/compiler/kde/src/KDE/kdelibs/knewstuff/knewstuff2/engine.cpp:185
#37 0xb706552a in KNS::Engine::download () at /home/compiler/kde/src/KDE/kdelibs/knewstuff/knewstuff2/engine.cpp:167
#38 0x08055f54 in KHangMan::slotDownloadNewStuff (this=0x81dac98) at /home/compiler/kde/src/KDE/kdeedu/khangman/src/khangman.cpp:367
#39 0x08056b6b in KHangMan::qt_metacall (this=0x81dac98, _c=QMetaObject::InvokeMetaMethod, _id=4, _a=0xbfbf6a9c) at /home/compiler/kde/build/KDE/kdeedu/khangman/src/khangman.moc:86
#40 0xb6e89bd0 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#41 0xb6e89fd0 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#42 0xb71a2841 in QAction::triggered () from /usr/lib/libQtGui.so.4
#43 0xb71a31af in QAction::activate () from /usr/lib/libQtGui.so.4
#44 0xb757c594 in ?? () from /usr/lib/libQtGui.so.4
#45 0xb757d022 in QMenu::mouseReleaseEvent () from /usr/lib/libQtGui.so.4
#46 0xb7ebcde5 in KMenu::mouseReleaseEvent (this=0x8300d80, e=0xbfbf723c) at /home/compiler/kde/src/KDE/kdelibs/kdeui/widgets/kmenu.cpp:452
#47 0xb7200b62 in QWidget::event () from /usr/lib/libQtGui.so.4
#48 0xb757f319 in QMenu::event () from /usr/lib/libQtGui.so.4
#49 0xb71a8b3c in QApplicationPrivate::notify_helper () from /usr/lib/libQtGui.so.4
#50 0xb71b1371 in QApplication::notify () from /usr/lib/libQtGui.so.4
#51 0xb7dded4d in KApplication::notify (this=0xbfbf78b0, receiver=0x8300d80, event=0xbfbf723c) at /home/compiler/kde/src/KDE/kdelibs/kdeui/kernel/kapplication.cpp:307
#52 0xb6e750d1 in QCoreApplication::notifyInternal () from /usr/lib/libQtCore.so.4
#53 0xb71b05fe in QApplicationPrivate::sendMouseEvent () from /usr/lib/libQtGui.so.4
#54 0xb721a3e7 in ?? () from /usr/lib/libQtGui.so.4
#55 0xb7218f81 in QApplication::x11ProcessEvent () from /usr/lib/libQtGui.so.4
#56 0xb7243548 in ?? () from /usr/lib/libQtGui.so.4
#57 0xb6e7379a in QEventLoop::processEvents () from /usr/lib/libQtCore.so.4
#58 0xb6e7395a in QEventLoop::exec () from /usr/lib/libQtCore.so.4
#59 0xb6e76015 in QCoreApplication::exec () from /usr/lib/libQtCore.so.4
#60 0xb71a89b7 in QApplication::exec () from /usr/lib/libQtGui.so.4
#61 0x08059f88 in main (argc=5, argv=0xbfbf7bb4) at /home/compiler/kde/src/KDE/kdeedu/khangman/src/main.cpp:137

Comment 3 FiNeX 2008-11-11 12:13:02 UTC
Bug reproduced in current trunk too (see bug #173320#c4).
Comment 4 smalcom 2008-11-11 19:41:33 UTC
*** Bug 173088 has been marked as a duplicate of this bug. ***
Comment 5 Rafael Fernández López 2008-11-12 00:05:41 UTC
I would love to see a test case on this.

I have written the kdelibs/kutils/kpluginselector.cpp which uses KFileItemDelegate, with a proxy model (filtering when searching) and I don't get any crashes, widgets are shown and hidden without any problems.
Comment 6 Rafael Fernández López 2008-11-12 00:09:20 UTC
*** Bug 173320 has been marked as a duplicate of this bug. ***
Comment 7 Stefan Böhmann 2008-11-12 04:16:01 UTC
Created attachment 28506 [details]
simple demo application

Simple demo: crash with KDE trunk (same backtrace as KNewStuff) but works as expected with KDE 4.1.x.
Comment 8 Rafael Fernández López 2008-11-12 10:22:10 UTC
Thank you for the test case. Adding this connect:

QObject::connect(lineEdit, SIGNAL(textChanged(QString)), proxy, SLOT(invalidate()));

helps out in positioning widgets correctly when filtering. However, I can still get the crash when I have some string and delete it fully (so all items should be added back).

I will have a look on this issue.
Comment 9 FiNeX 2008-11-12 14:00:01 UTC
*** Bug 174644 has been marked as a duplicate of this bug. ***
Comment 10 FiNeX 2008-11-12 14:00:07 UTC
*** Bug 171551 has been marked as a duplicate of this bug. ***
Comment 11 Rafael Fernández López 2008-11-12 18:33:04 UTC
SVN commit 883321 by ereslibre:

Use idx instead of index. This resolves some problems. I will also have a look on how to automatically update
the widget positions when the filter changes, for instance. For now, as before, you need to do something like:

connect(lineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(invalidate()));

BUG: 171991

 M  +1 -7      kwidgetitemdelegate.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=883321
Comment 12 Nicolas L. 2008-12-18 23:14:36 UTC
*** Bug 173320 has been marked as a duplicate of this bug. ***