diff --git a/common/geometry/shape_file_io.cpp b/common/geometry/shape_file_io.cpp index a87fd744fb..6bcbafb444 100644 --- a/common/geometry/shape_file_io.cpp +++ b/common/geometry/shape_file_io.cpp @@ -28,6 +28,13 @@ #include #include +SHAPE_FILE_IO::SHAPE_FILE_IO() +{ + m_groupActive = false; + m_mode = IOM_WRITE; + m_file = stdout; +} + SHAPE_FILE_IO::SHAPE_FILE_IO( const std::string& aFilename, SHAPE_FILE_IO::IO_MODE aMode ) { m_groupActive = false; @@ -61,7 +68,10 @@ SHAPE_FILE_IO::~SHAPE_FILE_IO() if( m_groupActive && m_mode != IOM_READ ) fprintf( m_file, "endgroup\n" ); - fclose( m_file ); + if ( m_file != stdout ) + { + fclose( m_file ); + } } @@ -143,4 +153,4 @@ void SHAPE_FILE_IO::Write( const SHAPE* aShape, const std::string aName ) fprintf( m_file, "shape %d %s %s\n", aShape->Type(), aName.c_str(), sh.c_str() ); fflush( m_file ); -} \ No newline at end of file +} diff --git a/include/geometry/shape_file_io.h b/include/geometry/shape_file_io.h index 78784d74ea..ce7bfa7906 100644 --- a/include/geometry/shape_file_io.h +++ b/include/geometry/shape_file_io.h @@ -45,6 +45,7 @@ class SHAPE_FILE_IO IOM_WRITE }; + SHAPE_FILE_IO(); SHAPE_FILE_IO( const std::string& aFilename, IO_MODE aMode = IOM_READ ); ~SHAPE_FILE_IO();