Commit d7ca3c00 authored by Tyler Wilson's avatar Tyler Wilson
Browse files

Fixed a segfault being caused in HistoryTreeWidget. Fixes #5096.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7974 41f8697f-d340-4b68-9986-7bafba869bb8
parent ccc57499
Loading
Loading
Loading
Loading
+40 −37
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ namespace Isis {

    setHeaderLabels(headers);


    connect(m_project, SIGNAL(workOrderStarting(WorkOrder *)),
            this, SLOT(addToHistory(WorkOrder *)));
    connect(m_project, SIGNAL(projectLoaded(Project *)),
@@ -37,6 +38,7 @@ namespace Isis {
  }



  /**
   * Clean up allocated memory
   */
@@ -105,8 +107,10 @@ namespace Isis {
   * @param workOrder The work order to display the history for
   */
  void HistoryTreeWidget::addToHistory(WorkOrder *workOrder) {

    QString data = workOrder->bestText();


    connect(workOrder, SIGNAL(destroyed(QObject *)),
                this, SLOT(removeFromHistory(QObject *)));

@@ -133,7 +137,8 @@ namespace Isis {
      newItem->setFont(1, progressFont);
      newItem->setForeground(1, Qt::gray);

      invisibleRootItem()->addChild(newItem);

      this->insertTopLevelItem(0,newItem);

      connect(workOrder, SIGNAL(statusChanged(WorkOrder *)),
                this, SLOT(updateStatus(WorkOrder *)));
@@ -142,12 +147,18 @@ namespace Isis {
      connect(workOrder, SIGNAL(deletingProgress(WorkOrder *)),
                this, SLOT(updateProgressWidgets()));


      //Sometimes the pointer returned by this call is 0 (hence the check).
      //So we are not creating a progress bar for every work order which would
      //include those that do not need it.

      if(workOrder->progressBar() )  {
        setItemWidget(newItem, 1, workOrder->progressBar());
        this->setItemWidget(newItem, 1, new ProgressBar );
      }

      scrollToItem(newItem);
      refit();
      return;

  }


@@ -160,14 +171,8 @@ namespace Isis {
   *   resize event.
   */
  void HistoryTreeWidget::updateProgressWidgets() {
    if(m_project->clearing()){
      return;
    }
    for (int i = 0; i < invisibleRootItem()->childCount(); i++) {
      QTreeWidgetItem *item = invisibleRootItem()->child(i);
      if (item->data(0, Qt::UserRole).isNull() ) {
        return;
      }
      WorkOrder *workOrder = item->data(0, Qt::UserRole).value<WorkOrder *>();

      if (workOrder && itemWidget(item, 1) != workOrder->progressBar()) {
@@ -286,8 +291,6 @@ namespace Isis {


  void HistoryTreeWidget::updateStatus(WorkOrder *workOrder) {
    if (undoCommandToTreeItem(workOrder)) {
    undoCommandToTreeItem(workOrder)->setText(1, workOrder->statusText());
  }
}
}
+9 −4
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@
#define HistoryTreeWidget_H

#include <QTreeWidget>
#include <QMutex>


class QResizeEvent;
class QUndoCommand;
@@ -28,9 +30,11 @@ namespace Isis {
   *                           out and italicized.
   *   @history 2017-04-05 Tracie Sucharski - For the last change, method name was changed from
   *                           onUndoStack to isUndoable.
   *   @history 2017-07-24 Cole Neubauer - Added check in addToHistory() to check if a WorkOrder
   *                           should be added to the HistoryTree Fixes #4715
   */
   *   @history 2017-08-10 Tyler Wilson - Changed some code in addToHistory function which
   *                            was causing a segfault.  This is a bandaid fix which
   *                            addresses the immediate problem, but will have to be tackled
   *                            in a future ticket.  Fixes #5096.  References #4492.
   * */
  class HistoryTreeWidget : public QTreeWidget {
      Q_OBJECT
    public:
@@ -43,6 +47,7 @@ namespace Isis {
    private:
      void refit();
      void updateStatus(QTreeWidgetItem *);
      QMutex m_mutex;

    private slots:
      void addToHistory(WorkOrder *);