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

Fixed a segfault in ImageList::save when Save As is called on certain projects. Fixes #5075.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7959 41f8697f-d340-4b68-9986-7bafba869bb8
parent e0409e0d
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -20,7 +20,11 @@
 *   http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
 *   http://www.usgs.gov/privacy.html.
 */
#include "Image.h"
#include "ImageList.h"
#include "IException.h"

#include <iostream>

#include <QAction>
#include <QColorDialog>
@@ -41,6 +45,8 @@
#include "Project.h"
#include "XmlStackedHandlerReader.h"

using namespace std;

namespace Isis {
  /**
   * Creates an image list from an image list name and path (does not read Images).
@@ -50,6 +56,7 @@ namespace Isis {
   * @param parent The Qt-relationship parent.
   */
  ImageList::ImageList(QString name, QString path, QObject *parent) : QObject(parent) {

    m_name = name;
    m_path = path;
  }
@@ -668,6 +675,7 @@ namespace Isis {
      actions.append(zoomFit);
    }


    return actions;
  }

@@ -778,7 +786,8 @@ namespace Isis {
   * @param newProjectRoot The path to the root directory for the new project.
   * 
   * @throws iException::Io "Failed to create directory"
   * @throws iException::Io "Unable to save image information because new file could not be opened for writing"
   * @throws iException::Io "Unable to save image information because new file could not
   *         be opened for writing"
   */
  void ImageList::save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot)
      const {
@@ -833,8 +842,15 @@ namespace Isis {
            .arg(newProgressValue, countWidth, 10, paddingChar)
            .arg(count()));
      progressDialog.setValue(newProgressValue);
      try {
          future.resultAt(i);
        }
      catch(std::exception &e) {
        QString msg("Could not save ImageList: "+this->name() );
        throw IException(IException::Io,msg,_FILEINFO_);
      }
    }


    progressLabel->setText(tr("Finalizing..."));
    progressDialog.setRange(0, 0);
@@ -892,7 +908,9 @@ namespace Isis {
   * @see save
   */
  void *ImageList::CopyImageDataFunctor::operator()(Image * const &imageToCopy) {

    imageToCopy->copyToNewProjectRoot(m_project, m_newProjectRoot);

    return NULL;
  }

+5 −3
Original line number Diff line number Diff line
@@ -42,8 +42,10 @@ namespace Isis {
   *                         changes, update the serial number list.
   * @history 2017-06-08 Makayla Shepherd - Modified ImageList(QStringList &) to close the image
   *                         cubes after adding them to the list. Fixes #4908.
   * @history 2017-08-04 Marjorie Hahn - Turned Bring to Front, Bring Forward, Send to Back, Send 
   *                         Backwards, and Zoom Fit into work orders. Fixes #5055.
   * @history 2017-07-08 Tyler Wilson - Added a try-catch block in ImageList::saveQXmlStreamWriter
   *                         &stream, const Project *project, FileName newProjectRoot) to
   *                         stop a seg fault occurring when Save As is called on certain types
   *                         of corrupt projects.  Fixes #5075.
   */
  class ImageList : public QObject, public QList<Image *> {
    Q_OBJECT