Fix for preferences crash by Vincent van Ravesteijn.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26054 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2008-08-04 15:50:56 +00:00
parent 6c591d9fd0
commit 5861442f6f

View File

@ -117,15 +117,20 @@ void PanelStack::setCurrentPanel(QString const & name)
void PanelStack::switchPanel(QTreeWidgetItem * item, void PanelStack::switchPanel(QTreeWidgetItem * item,
QTreeWidgetItem * previous) QTreeWidgetItem * previous)
{ {
// do nothing when clicked on whitespace (item=NULL)
if( !item )
return;
// if we have a category, expand the tree and go to the // if we have a category, expand the tree and go to the
// first item // first item
if (item->childCount() > 0) { if (item->childCount() > 0) {
item->setExpanded(true); item->setExpanded(true);
if (previous != item->child(0)) if (previous && previous->parent() != item)
list_->setCurrentItem(item->child(0)); switchPanel( item->child(0), previous );
} }
if (QWidget * w = widget_map_.value(item, 0)) else
stack_->setCurrentWidget(w); if (QWidget * w = widget_map_.value(item, 0))
stack_->setCurrentWidget(w);
} }