]> git.sur5r.net Git - bacula/bacula/commitdiff
dhb Fix of a segfault. The clear() function would execute triggering
authorDirk H Bartley <dbartley@schupan.com>
Tue, 3 Apr 2007 02:32:29 +0000 (02:32 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Tue, 3 Apr 2007 02:32:29 +0000 (02:32 +0000)
     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

bacula/src/qt-console/medialist/medialist.cpp
bacula/src/qt-console/medialist/medialist.h

index 628b89782b68cba78fac9bb2bb4b3d21ee4c61b5..855f66b1a55a6d235373a52ae4607f04c8acbb34 100644 (file)
@@ -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);
+      }
    }
 }
index a1154307f92ed795fb1b7e8377a7b0c824192f43..a29e30dbcca44a89164b791a799156b28f3d69f2 100644 (file)
@@ -63,6 +63,7 @@ private:
    Console *mp_console;
    QString m_currentlyselected;
    bool m_populated;
+   bool m_checkcurwidget;
 };
 
 #endif /* _MEDIALIST_H_ */