Commit 9389eb3f authored by Jeannie Backer's avatar Jeannie Backer
Browse files

ImageOverlapSet added unlock calls just before error throws. Replaced...

ImageOverlapSet added unlock calls just before error throws. Replaced deprecated IStrings with QStrings.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7142 41f8697f-d340-4b68-9986-7bafba869bb8
parent e8bd0ce4
Loading
Loading
Loading
Loading
+18 −12
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ namespace Isis {
      if(!tmp->isValid()) {
        delete tmp;
        tmp = NULL;
        IString msg = "The image [" + sns.fileName(sns.serialNumber(i)) +
        QString msg = "The image [" + sns.fileName(sns.serialNumber(i)) +
                      "] has an invalid footprint";
        throw IException(IException::Programmer, msg, _FILEINFO_);
      }
@@ -328,12 +328,13 @@ namespace Isis {
   */
  void ImageOverlapSet::ReadImageOverlaps(const QString &filename) {
    
    IString file = FileName(filename).expanded();
    QString file = FileName(filename).expanded();

    try {
      // Let's get an istream pointed at our file
      std::ifstream inStream;
      inStream.open(file.c_str(), fstream::in | fstream::binary);
      QByteArray fileArray = file.toLatin1();
      inStream.open(fileArray.constData(), fstream::in | fstream::binary);

      while (!inStream.eof()) {
        p_lonLatOverlapsMutex.lock();
@@ -344,12 +345,14 @@ namespace Isis {
      inStream.close();
    }
    catch (IException &e) {
      IString msg = "The overlap file [" + filename + "] does not contain a "
      p_lonLatOverlapsMutex.unlock();
      QString msg = "The overlap file [" + filename + "] does not contain a "
                    "valid list of image overlaps";
      throw IException(e, IException::Unknown, msg, _FILEINFO_);
    }
    catch (...) {
      IString msg = "The overlap file [" + filename + "] does not contain a "
      p_lonLatOverlapsMutex.unlock();
      QString msg = "The overlap file [" + filename + "] does not contain a "
                    "valid list of image overlaps";
      throw IException(IException::Unknown, msg, _FILEINFO_);
    }
@@ -443,7 +446,7 @@ namespace Isis {
   */
  void ImageOverlapSet::WriteImageOverlaps(const QString &filename) {
        
    IString file = FileName(filename).expanded();
    QString file = FileName(filename).expanded();
    bool failed = false;
    bool noOverlaps = false;
    if (p_threadedCalculate) {
@@ -454,11 +457,12 @@ namespace Isis {
      // Let's get an ostream pointed at our file
      std::ofstream outStream;

      QByteArray fileArray = file.toLatin1();
      if (p_writtenSoFar == 0) {
        outStream.open(file.c_str(), fstream::out | fstream::trunc | fstream::binary);
        outStream.open(fileArray.constData(), fstream::out | fstream::trunc | fstream::binary);
      }
      else {
        outStream.open(file.c_str(), fstream::out | fstream::app | fstream::binary);
        outStream.open(fileArray.constData(), fstream::out | fstream::app | fstream::binary);
      }

      failed |= outStream.fail();
@@ -513,11 +517,13 @@ namespace Isis {
    }

    if (failed) {
      IString msg = "Unable to write the image overlap list to [" + filename + "]";
      p_calculatePolygonMutex.unlock();
      QString msg = "Unable to write the image overlap list to [" + filename + "]";
      throw IException(IException::Io, msg, _FILEINFO_);
    }
    else if (noOverlaps) {
      IString msg = "No overlaps were found.";
      p_calculatePolygonMutex.unlock();
      QString msg = "No overlaps were found.";
      throw IException(IException::User, msg, _FILEINFO_);
    }
  }
+39 −37
Original line number Diff line number Diff line
@@ -55,42 +55,44 @@ namespace Isis {
   *
   * @internal
   *   @history 2008-06-18 Christopher Austin - Fixed documentation
   *  @history 2008-08-18 Steven Lambright - Updated to work with geos3.0.0
   *           instead of geos2. Mostly namespace changes.
   *  @history 2008-11-24 Steven Lambright - Improved upon error reporting. Added
   *           the Errors() method.
   *  @history 2008-11-25 Steven Koechle - Moved Despike Methods from
   *           ImageOverlapSet to PolygonTools
   *  @history 2008-12-10 Steven Koechle - Moved MakeMultiPolygon Method from
   *           ImageOverlapSet to PolygonTools
   *  @history 2008-12-05 Steven Lambright - Checking footprints for validity now,
   *           fixed an issue with the intersection operator where an invalid but
   *           repairable polygon is produced, and fixed a memory leak.
   *  @history 2008-12-15 Steven Koechle - Fixed to read new footprint blob naming
   *           scheme.
   *  @history 2009-01-06 Steven Koechle - Removed backwards compatibility for old
   *           footprint blob name. Added a throw if footprints are invalid in an
   *           image.
   *  @history 2009-01-07 Steven Lambright & Christopher Austin - Fixed handling
   *           of Despike(...) throwing errors on empty polygons
   *  @history 2009-01-13 Steven Lambright - Deletes both overlaps if an
   *           intersection fails for an unknown reason.
   *  @history 2009-01-28 Steven Lambright - Fixed memory leaks
   *  @history 2009-03-12 Christopher Austin - Added the MULTIPOLYGON to
   *           HandleError() as the Keyword "Polygon"
   *  @history 2009-06-01 Christopher Austin - Changed the basic algorithm to
   *           improve results.
   *  @history 2009-06-01 Steven Lambright - Multi-threaded this object. Split
   *           code into smaller methods, now new elements are inserted next
   *           instead of appended to the end of the overlap list, and added more
   *           error-recovery solutions.
   *  @history 2010-09-27 Christopher Austin - Added an error when no new overlaps
   *           are calculated. (i.e. All overlaps contain only a single Serial Number)
   *  @history 2011-03-29 Steven Lambright - Added some safety around
   *           p_lonLatOverlaps to (hopefully) get rid of a race condition.
   *  @history 2016-09-14 Marjorie Hahn - Modified FindAllOverlaps()'s check to ensure 
   *           that at least one overlap has been calculated by adding in the 
   *           "foundOverlap" boolean. References #2199.
   *   @history 2008-08-18 Steven Lambright - Updated to work with geos3.0.0 instead of geos2.
   *                           Mostly namespace changes.
   *   @history 2008-11-24 Steven Lambright - Improved upon error reporting.
   *                           Added the Errors() method.
   *   @history 2008-11-25 Steven Koechle - Moved Despike Methods from ImageOverlapSet to
   *                           PolygonTools.
   *   @history 2008-12-10 Steven Koechle - Moved MakeMultiPolygon Method from ImageOverlapSet to
   *                           PolygonTools.
   *   @history 2008-12-05 Steven Lambright - Checking footprints for validity now, fixed an issue
   *                           with the intersection operator where an invalid but repairable
   *                           polygon is produced, and fixed a memory leak.
   *   @history 2008-12-15 Steven Koechle - Fixed to read new footprint blob naming scheme.
   *   @history 2009-01-06 Steven Koechle - Removed backwards compatibility for old footprint blob
   *                           name. Added a throw if footprints are invalid in an image.
   *   @history 2009-01-07 Steven Lambright & Christopher Austin - Fixed handling of Despike(...)
   *                           throwing errors on empty polygons.
   *   @history 2009-01-13 Steven Lambright - Deletes both overlaps if an intersection fails for an
   *                           unknown reason.
   *   @history 2009-01-28 Steven Lambright - Fixed memory leaks.
   *   @history 2009-03-12 Christopher Austin - Added the MULTIPOLYGON to HandleError() as the
   *                           Keyword "Polygon".
   *   @history 2009-06-01 Christopher Austin - Changed the basic algorithm to improve results.
   *   @history 2009-06-01 Steven Lambright - Multi-threaded this object. Split code into smaller
   *                           methods, now new elements are inserted next instead of appended to
   *                           the end of the overlap list, and added more error-recovery solutions.
   *   @history 2010-09-27 Christopher Austin - Added an error when no new overlaps are calculated.
   *                           (i.e. All overlaps contain only a single Serial Number).
   *   @history 2011-03-29 Steven Lambright - Added some safety around p_lonLatOverlaps to
   *                           (hopefully) get rid of a race condition.
   *   @history 2016-08-26 Kelvin Rodriguez - Added tryLock() just before unlocking mutex in
   *                           FindAllOverlaps() to avoid undefined behavior. This was done to
   *                           prevent compile errors on MAC OS 10.11.
   *   @history 2016-09-14 Marjorie Hahn - Modified FindAllOverlaps()'s check to ensure that at
   *                           least one overlap has been calculated by adding in the "foundOverlap"
   *                           boolean. References #2199.
   *   @history 2016-09-28 Jeannie Backer - Replaced deprecated IStrings with QStrings. Added mutex
   *                          unlock() calls immediately before exception calls to prevent warning
   *                          message by latest Qt library 5.7.
   */
  class ImageOverlapSet : private QThread {
    public: