Commit 042be2d1 authored by Ian Humphrey's avatar Ian Humphrey
Browse files

Trying to select a control point within an image that has no control points...

Trying to select a control point within an image that has no control points gives a warning instead of crashing. Fixes #2210.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6193 41f8697f-d340-4b68-9986-7bafba869bb8
parent f58ef0ad
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

#include <QApplication>
#include <QMenu>
#include <QMessageBox>
#include <QSize>

#include "Angle.h"
@@ -534,6 +535,7 @@ namespace Isis {
  void AdvancedTrackTool::TrackMosaicOrigin(MdiCubeViewport *cvp, int piLine,
      int piSample, int &piOrigin, QString &psSrcFileName,
      QString &psSrcSerialNum) {
      try {
        Cube *cCube = cvp->cube(); 
        int iTrackBand = -1;
        
@@ -556,7 +558,6 @@ namespace Isis {
                              cCube->pixelType());
            cOrgPortal.SetPosition(piSample, piLine, iTrackBand + 1); // 1 based
            cCube->read(cOrgPortal);

            piOrigin = (int)cOrgPortal[0];
            switch(SizeOf(cCube->pixelType())) {
              case 1:
@@ -583,6 +584,11 @@ namespace Isis {
          }
        }
      } 
      catch (IException &e) {
          QMessageBox::warning((QWidget *)parent(), "Warning", e.toString());
      }
      
  }


  /**
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ namespace Isis {
   *  @history 2014-06-17 Jeannie Backer - Modified to print set value to empty strings for
   *                          photometric angles, azimuths, resolutions if not valid.
   *                          References #1659.
   *  @history 2015-05-13 Makayla Shepherd - Modified to improve handling of undefined slot behavior.
   *                          References #2210.
   */
  class AdvancedTrackTool : public Tool {
      Q_OBJECT
+16 −2
Original line number Diff line number Diff line
@@ -1486,7 +1486,10 @@ namespace Isis {
   * @history 2013-12-17 Tracie Sucharski - Check for valid serial number at beginning.  This 
   *                          prevents seg fault if user opens a new cube list but clicks on a
   *                          cube that was open from a previous list.
   *
   * @history 2015-05-13 Ian Humphrey and Makayla Shepherd - Add try/catch when trying to find 
   *                          closest control point. Since FindClosest() can throw exceptions, 
   *                          we need to handle them within this connected slot to avoid undefined
   *                          behavior.
   */
  void QnetTool::mouseButtonRelease(QPoint p, Qt::MouseButton s) {
    MdiCubeViewport *cvp = cubeViewport();
@@ -1527,10 +1530,20 @@ namespace Isis {

      //  Find closest control point in network
      QString sn = m_serialNumberList->SerialNumber(file);
      ControlPoint *point = m_controlNet->FindClosest(sn, samp, line);
      
      // since we are in a connected slot, we need to handle exceptions thrown by FindClosest
      try {
        ControlPoint *point = m_controlNet->FindClosest(sn, samp, line);
        modifyPoint(point);
      }
      catch (IException &ie) {
        QString message = "No points exist for editing. Create points using the right mouse";
        message += " button.";
        QMessageBox::warning(m_qnetTool, "Warning", message);
        return;
      }
    }
    
    else if (s == Qt::MidButton) {
      if (!m_controlNet || m_controlNet->GetNumPoints() == 0) {
        QString message = "No points exist for deleting.  Create points ";
@@ -3616,6 +3629,7 @@ namespace Isis {
    m_groundOpen = true;

    m_workspace->addCubeViewport(m_groundCube.data());
    
    //  Get viewport so connect can be made when ground source viewport closed to clean up
    // ground source
    MdiCubeViewport *vp;
+4 −0
Original line number Diff line number Diff line
@@ -213,6 +213,10 @@ namespace Isis {
   *                          need to be called from setPointType.  This avoids reloading the point
   *                          in case the ignored flag has been changed, but measure has not been
   *                          saved.  References #1603.
   * @history 2015-05-13 Ian Humphrey and Makayla Shepherd - Modified mouseButtonRelease to 
   *                         correctly handle expections thrown when find the closest control point.
   *                         Updated the message displayed to user to be more informative. 
   *                         Fixes #2210.
   */
  class QnetTool : public Tool {
    Q_OBJECT
+10 −1
Original line number Diff line number Diff line
@@ -317,7 +317,9 @@ namespace Isis {
   *           since this was causing a segfault and this
   *           deallocation is already taking place in
   *           addCubeViewport(cube).
   *
   *  @history 2015-05-13 Ian Humphrey - Caught exception now handled by sending a QMessageBox
   *                          to the Workspace. This prevents undefined behavior caused by not 
   *                          handling an exception within a connected slot.
   */
  void Workspace::addCubeViewport(QString cubename) {
    Cube *cube = new Cube;
@@ -330,6 +332,8 @@ namespace Isis {
    cube->setVirtualBands(bands);
    cube->open(cubename);

    // this slot is connected to FileTool fileSelected signal
    try {
      MdiCubeViewport *cvp = addCubeViewport(cube);

      // Check for RGB format (#R,#G,#B)
@@ -343,6 +347,11 @@ namespace Isis {
        cvp->viewRGB(index_red, index_green, index_blue);
      }
    }
    catch (IException &e) {
      QMessageBox::critical((QWidget *)parent(), "Error", e.toString());
      return;
    }
  }

  /**
   * Add a cubeViewport to the workspace.
Loading