Commit 3c7c70b5 authored by Makayla Shepherd's avatar Makayla Shepherd
Browse files

Fixed a seg fault that occurs when closing a cube footprint. Fixes #5050

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7897 41f8697f-d340-4b68-9986-7bafba869bb8
parent fe9a749c
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -89,6 +89,9 @@ namespace Isis {
    connect(m_sceneWidget, SIGNAL(createControlPoint(double, double)),
            this, SIGNAL(createControlPoint(double, double)));
    
    connect(m_sceneWidget, SIGNAL(mosCubeClosed(Image *)), 
            this, SLOT(onMosItemRemoved(Image *)));

    // Pass on signals emitted from Directory (by way of ControlPointEditWidget)
    // This is done to redraw the control points on the cube viewports
    connect(this, SIGNAL(controlPointAdded(QString)),
@@ -244,6 +247,27 @@ namespace Isis {
  }

  
  /**
   * Slot at removes the mosaic item and corresponding image file list item when a cube is closed 
   * using the Close Cube context menu.
   * 
   * @param image The image that was closed and needs to be removed
   */
  void Footprint2DView::onMosItemRemoved(Image *image) {
    if (image) {
      ImageList images;
      images.append(image);

      m_sceneWidget->removeImages(images);
      m_fileListWidget->removeImages(&(images));

      if ( m_imageItemMap.value( image ) ) {
        m_imageItemMap.remove( image );
      }
    }
  }
  

  /**
   * Slot to connect to the itemRemoved signal from the model. If the item is an image it removes it
   * from the scene.
+3 −0
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ namespace Isis {
   *   @history 2017-02-06 Tracie Sucharski - Added status bar for the track tool.  Fixes #4475.
   *   @history 2017-07-18 Cole Neubauer - Moved creation of the ImageFileListWidget into
   *                           Footprint2DView to more mirror the Qmos window.  Fixes #4996.
   *   @history 2017-07-27 Makayla Shepherd - Fixed a segfault that occurred when closing a cube
   *                           footprint. Fixes #5050.
   */
  class Footprint2DView : public AbstractProjectItemView {

@@ -90,6 +92,7 @@ namespace Isis {
      void onItemAdded(ProjectItem *item);
      void onItemRemoved(ProjectItem *item);
      void onQueueSelectionChanged();
      void onMosItemRemoved(Image *image);

    private:
      MosaicSceneWidget *m_sceneWidget; //!< The scene widget
+16 −2
Original line number Diff line number Diff line
@@ -588,8 +588,14 @@ namespace Isis {

      menu.addSeparator();
      QAction *removeAction = menu.addAction("Close Cube");
      
      if (QApplication::applicationName() == "qmos") {
        connect(removeAction, SIGNAL(triggered()),
                m_image, SLOT(deleteLater()));
      }
      else {
        connect(removeAction, SIGNAL(triggered()), SLOT(onCloseCube()));
      }

      menu.exec(event->screenPos());
    }
@@ -602,6 +608,14 @@ namespace Isis {
  }


  /**
   * Emits a signal when Close Cube is selected from the context menu
   */
  void MosaicSceneItem::onCloseCube() {
    emit mosaicCubeClosed(m_image);
  }
  
  
  /**
   * This applies the displayProperties and selectability. It's
   *   called updateChildren because the child items are the
+4 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ namespace Isis {
   *                          Fixes #2208.
   *  @history 2016-05-18 Ian Humphrey - Explicitly made outlines cosmetic so that they always
   *                          appear as 1 pixel wide on screen (Qt4 to Qt5).
   *  @history 2017-07-27 Makayla Shepherd - Fixed a segfault that occurred when closing a cube
   *                          footprint. Fixes #5050.
   */
  class MosaicSceneItem : public QGraphicsObject {
      Q_OBJECT
@@ -68,6 +70,7 @@ namespace Isis {
    signals:
      void colorChanged();
      void changed(const QList<QRectF> &);
      void mosaicCubeClosed(Image *);

    public slots:
      void cubeDisplayChanged();
@@ -80,6 +83,7 @@ namespace Isis {

    private slots:
      void lostCubeDisplay();
      void onCloseCube();

    private:
      MosaicSceneItem(const MosaicSceneItem &); //!< cannot copy
+2 −0
Original line number Diff line number Diff line
@@ -1296,6 +1296,8 @@ namespace Isis {

      connect(mosItem, SIGNAL(changed(const QList<QRectF> &)),
              m_graphicsView, SLOT(updateScene(const QList<QRectF> &)));
      connect(mosItem, SIGNAL(mosaicCubeClosed(Image *)), 
              this, SIGNAL(mosCubeClosed(Image *)));

      // We want everything to have a unique Z value so we can manage the z order
      //   well.
Loading