Bug 363251

Summary: setting `Value to nil in SelectionBox segfaults
Product: [openSUSE] openSUSE 11.0 Reporter: Arvin Schnell <aschnell>
Component: YaST2Assignee: Stefan Hundhammer <shundhammer>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Major    
Priority: P5 - None    
Version: Alpha 2   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Development Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Arvin Schnell 2008-02-20 13:56:46 UTC
Setting the `Value to nil in SelectionBox causes Segfault.

Found in example Events.ycp ("Special..." -> "Candel order").
Comment 1 Stefan Hundhammer 2008-02-29 16:40:17 UTC
No longer segfaults, but also doesn't properly deselect.
Comment 2 Stefan Hundhammer 2008-03-04 13:28:20 UTC
Arg. This bug seems to have been introduced intentionally. I just can't believe this.

void YQSelectionBox::deselectAllItems()
{
    YSelectionBox::deselectAllItems();
    _qt_listBox->clearSelection();

    if ( _qt_listBox->currentRow() > -1 )
    {
	// Some item is selected after all; the Qt documtation says this
	// happens if the QListBox is in single selection mode (which it is)
	// and has the keyboard focus.
	//
	// Synchronize internal "selected" flags with what the QListBox
	// displays. This has a small performance penalty because it calls
	// YSelectionBox::deselectAllItems() again which again iterates over
	// all items.
	selectItem( _qt_listBox->row(_qt_listBox->currentItem()) );
    }
}


Well, this is clearly too cheap.
Comment 3 Stefan Hundhammer 2008-03-04 15:44:14 UTC
It still segfaults.
Comment 4 Stefan Hundhammer 2008-03-04 15:45:22 UTC
2008-03-04 16:43:17 <1> snell(32541) [YCP] examples/Events.ycp:19 formatEvent($["EventSerialNo":6, "EventType":"MenuEvent", "ID":`cancel_order])
2008-03-04 16:43:17 <1> snell(32541) [YCP] examples/Events.ycp:252 Cancelling order
2008-03-04 16:43:17 <3> snell(32541) [qt-ui] src/YQUI_core.cc(qMessageHandler):611 <qt-fatal> ASSERT: "!isEmpty()" in file /usr/include/QtCore/qlist.h, line 229
2008-03-04 16:43:17 <3> snell(32541) [liby2] genericfrontend.cc(signal_handler):133 got signal 6 at YCP file /local_home/sh/yast2/trunk/ycp-ui-bindings/examples/Events.ycp:254
2008-03-04 16:43:17 <3> snell(32541) [liby2] genericfrontend.cc(log_backtrace):81 Back trace:

   Frame  0: /usr/lib/liby2.so.2  log_backtrace()
   Frame  1: /usr/lib/liby2.so.2  signal_handler(int)
   Frame  2: [0xb7f92420]
   Frame  3: [0xb7f92410]
   Frame  4: /lib/libc.so.6(abort+0x101) [0xb7a03801]
   Frame  5: /usr/lib/YaST2/plugin/libpy2qt.so.2 [0xb66de6b5]
   Frame  6: /usr/lib/libQtCore.so.4  qt_message_output(QtMsgType, char const*)
   Frame  7: /usr/lib/libQtCore.so.4  qFatal(char const*, ...)
   Frame  8: /usr/lib/libQtCore.so.4  qt_assert(char const*, char const*, int)
   Frame  9: /usr/lib/YaST2/plugin/libpy2qt.so.2  QList<QListWidgetItem*>::first()
   Frame 10: /usr/lib/YaST2/plugin/libpy2qt.so.2  YQSelectionBox::slotSelectionChanged()
   Frame 11: /usr/lib/YaST2/plugin/libpy2qt.so.2  YQSelectionBox::qt_metacall(QMetaObject::Call, int, void**)
   Frame 12: /usr/lib/libQtCore.so.4  QMetaObject::activate(QObject*, int, int, void**)
   Frame 13: /usr/lib/libQtCore.so.4  QMetaObject::activate(QObject*, QMetaObject const*, int, void**)
   Frame 14: /usr/lib/libQtGui.so.4  QListWidget::itemSelectionChanged()
   Frame 15: /usr/lib/libQtGui.so.4  QListWidget::qt_metacall(QMetaObject::Call, int, void**)
   Frame 16: /usr/lib/libQtCore.so.4  QMetaObject::activate(QObject*, int, int, void**)
   Frame 17: /usr/lib/libQtCore.so.4  QMetaObject::activate(QObject*, QMetaObject const*, int, void**)
   Frame 18: /usr/lib/libQtGui.so.4  QItemSelectionModel::selectionChanged(QItemSelection const&, QItemSelection const&)
   Frame 19: /usr/lib/libQtGui.so.4  QItemSelectionModel::clearSelection()
   Frame 20: /usr/lib/libQtGui.so.4  QAbstractItemView::clearSelection()
   Frame 21: /usr/lib/YaST2/plugin/libpy2qt.so.2  YQSelectionBox::deselectAllItems()
   Frame 22: /usr/lib/YaST2/plugin/libpy2UI.so.2  bool trySetSelectionWidgetValue<YSelectionBox, YCPItem>(YWidget*, YCPValue const&)
   Frame 23: /usr/lib/YaST2/plugin/libpy2UI.so.2  YCPPropertyHandler::trySetSelectionBoxValue(YWidget*, YCPValue const&)
   Frame 24: /usr/lib/YaST2/plugin/libpy2UI.so.2  YCPPropertyHandler::setComplexProperty(YWidget*, std::string const&, YCPValue const&)
   Frame 25: /usr/lib/YaST2/plugin/libpy2UI.so.2  YCP_UI::ChangeWidget(YCPValue const&, YCPValue const&, YCPValue const&)
   Frame 26: /usr/lib/YaST2/plugin/libpy2UI.so.2  YUINamespace::ChangeWidget(YCPSymbol const&, YCPSymbol const&, YCPValue const&)
   Frame 27: /usr/lib/YaST2/plugin/libpy2UI.so.2  YUIFunction::evaluateCall_int()
   Frame 28: /usr/lib/YaST2/plugin/libpy2UI.so.2  YCPBuiltinCaller::call()
   Frame 29: /usr/lib/libyui.so.3  YUI::uiThreadMainLoop()
   Frame 30: /usr/lib/libyui.so.3  start_ui_thread(void*)
   Frame 31: /lib/libpthread.so.0 [0xb7d06112]
   Frame 32: /lib/libc.so.6(clone+0x5e) [0xb7a982ee]

== End of back trace ===
Comment 5 Stefan Hundhammer 2008-03-04 16:58:06 UTC
Fixed the segfault (caused by false assumption that the list returned by QListWidget::selectedItems() can be used with QList::first() if it is empty) and also deselecting the items: QListWidget::setCurrentItem(-1) does the trick, even if single selection is set.
Comment 6 Stefan Hundhammer 2008-03-04 16:59:34 UTC
Fix available with yast2-qt-2.16.32.