Commit 1e6ef375 authored by Adam Goins's avatar Adam Goins
Browse files

Fixed qview segfault when editing non-writable cube. #Fixes 2097

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@8100 41f8697f-d340-4b68-9986-7bafba869bb8
parent f301fba1
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -279,12 +279,15 @@ m_container = container;
    if (vp == NULL) return;

    if (vp->cube()->isReadOnly()) {

      QString fileName = vp->cube()->fileName();
      //  ReOpen cube as read/write
      //  If cube readonly print error
      try {
        vp->cube()->reopen("rw");
      }
      catch(IException &) {
        vp->cube()->open(fileName, "r");
        QMessageBox::information((QWidget *)parent(), "Error", "Cannot open cube read/write");
        return;
      }
@@ -400,6 +403,10 @@ m_container = container;
   *                             the mouseButtonRelease and moved
   *                             it to the rubberBandComplete
   *                             method.
   * @history  2017-08-11 Adam Goins - Added a "vp->cube()->open("r")" call to reopen the cube with
   *                               "r" permissions if the attempted "rw" permission didn't succeed.
   *                               Fixes segfault issue if editing is attempted on cube without "w" access.
   *                               (ref # 2097)
   */
  void EditTool::mouseButtonRelease(QPoint p, Qt::MouseButton m) {
    MdiCubeViewport *vp = cubeViewport();
@@ -410,12 +417,17 @@ m_container = container;

    //  If cube readonly try to open read/write
    if (vp->cube()->isReadOnly()) {

      // Get cube filename to recreate it with "r" privileges if the "rw" access fails.
      QString fileName = vp->cube()->fileName();

      //  ReOpen cube as read/write
      //  If cube readonly print error
      try {
        vp->cube()->reopen("rw");
      }
      catch(IException &) {
        vp->cube()->open(fileName, "r");
        QMessageBox::information((QWidget *)parent(), "Error", "Cannot open cube read/write");
        return;
      }
+4 −0
Original line number Diff line number Diff line
@@ -76,6 +76,10 @@ namespace Isis {
   *                            now appears if you have edited your file but not saved it - not when
   *                            clicking "Save." This was a minimal fix (I left a lot of problems
   *                            to be solved at a later date). Fixes #854.
   *   @history  2017-08-11 Adam Goins - Added a line of code to recreate a cube with "r" permissions
   *                            attempting to open it with "rw" permission failed. This fixes an issue
   *                            where the cube would segfault if it was being edited without "w" permission.
   *                            Fixes # 2097 
   */
  class EditTool : public Tool {
      Q_OBJECT