From: Dirk H Bartley Date: Tue, 3 Apr 2007 02:32:29 +0000 (+0000) Subject: dhb Fix of a segfault. The clear() function would execute triggering X-Git-Tag: Release-7.0.0~6623 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bb7342dadc15338ef5d2d397f900113d82802fa3;p=bacula%2Fbacula dhb Fix of a segfault. The clear() function would execute triggering a treeItemChanged when no tree item exits because of the clear. There is probably a cleaner way to accomplish this prevent of segfault. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4503 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index 628b89782b..855f66b1a5 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -51,6 +51,7 @@ MediaList::MediaList(QStackedWidget *parent, Console *console, QTreeWidgetItem * mp_console = console; createConnections(); m_populated = false; + m_checkcurwidget = true; } MediaList::~MediaList() @@ -78,7 +79,9 @@ void MediaList::populateTree() << "Volume Bytes" << "Volume Files" << "Volume Retention" << "Media Type" << "Last Written"); + m_checkcurwidget = false; mp_treeWidget->clear(); + m_checkcurwidget = true; mp_treeWidget->setColumnCount(9); topItem = new QTreeWidgetItem(mp_treeWidget); topItem->setText(0, "Pools"); @@ -173,8 +176,6 @@ void MediaList::treeItemDoubleClicked(QTreeWidgetItem * /*item*/, int /*column*/ */ void MediaList::editMedia() { - /* ***FIXME*** make sure a valid tree item is selected -- check currentItem - * ??? Should this be a check in the database for the existence of m_currentlyselected??*/ MediaEdit* edit = new MediaEdit(mp_console, m_currentlyselected); edit->show(); } @@ -213,14 +214,17 @@ void MediaList::PgSeltreeWidgetDoubleClicked() /* * Added to set the context menu policy based on currently active treeWidgetItem + * signaled by currentItemChanged */ void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetItem *) /*previouswidgetitem*/ { - int treedepth = currentwidgetitem->data(0, Qt::UserRole).toInt(); - if (treedepth == 2){ - mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu); - m_currentlyselected=currentwidgetitem->text(1); - } else { - mp_treeWidget->setContextMenuPolicy(Qt::NoContextMenu); + if ( m_checkcurwidget ) { + int treedepth = currentwidgetitem->data(0, Qt::UserRole).toInt(); + if (treedepth == 2){ + mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu); + m_currentlyselected=currentwidgetitem->text(1); + } else { + mp_treeWidget->setContextMenuPolicy(Qt::NoContextMenu); + } } } diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index a1154307f9..a29e30dbcc 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -63,6 +63,7 @@ private: Console *mp_console; QString m_currentlyselected; bool m_populated; + bool m_checkcurwidget; }; #endif /* _MEDIALIST_H_ */