Skip to content

Commit

Permalink
Bugfix: when saving a project and there is insufficient space on the …
Browse files Browse the repository at this point in the history
…volume, handle the problem gracefully. Also fixed qgisapp so that failed project saving before app exiting halts app exit properly

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9456 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Oct 8, 2008
1 parent 515dfd3 commit 8c2c083
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -3133,13 +3133,15 @@ bool QgisApp::fileSave()
QMessageBox::critical( this,
tr( "Unable to save project" ),
tr( "Unable to save project to " ) + QgsProject::instance()->fileName() );
return false;
}
}
catch ( std::exception & e )
{
QMessageBox::critical( this,
tr( "Unable to save project " ) + QgsProject::instance()->fileName(),
QString::fromLocal8Bit( e.what() ) );
return false;
}
return true;
} // QgisApp::fileSave
Expand Down
12 changes: 12 additions & 0 deletions src/core/qgsproject.cpp
Expand Up @@ -1015,6 +1015,18 @@ bool QgsProject::write()
doc->save( projectFileStream, 4 ); // save as utf-8
imp_->file.close();

// check if the text stream had no error - if it does
// the user will get a message so they can try to resolve the
// situation e.g. by saving project to a volume with more space
//
if ( projectFileStream.pos() == -1 || imp_->file.error() != QFile::NoError)
{
throw QgsIOException( QObject::tr( "Unable to save to file. Your project "
"may be corrupted on disk. Try clearing some space on the volume and "
"check file permissions before pressing save again." ) +
imp_->file.fileName() );
return false;
}

dirty( false ); // reset to pristine state

Expand Down

0 comments on commit 8c2c083

Please sign in to comment.