Skip to content

Commit 8c2c083

Browse files
author
timlinux
committed
Bugfix: when saving a project and there is insufficient space on the 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
1 parent 515dfd3 commit 8c2c083

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/app/qgisapp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3133,13 +3133,15 @@ bool QgisApp::fileSave()
31333133
QMessageBox::critical( this,
31343134
tr( "Unable to save project" ),
31353135
tr( "Unable to save project to " ) + QgsProject::instance()->fileName() );
3136+
return false;
31363137
}
31373138
}
31383139
catch ( std::exception & e )
31393140
{
31403141
QMessageBox::critical( this,
31413142
tr( "Unable to save project " ) + QgsProject::instance()->fileName(),
31423143
QString::fromLocal8Bit( e.what() ) );
3144+
return false;
31433145
}
31443146
return true;
31453147
} // QgisApp::fileSave

src/core/qgsproject.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,18 @@ bool QgsProject::write()
10151015
doc->save( projectFileStream, 4 ); // save as utf-8
10161016
imp_->file.close();
10171017

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

10191031
dirty( false ); // reset to pristine state
10201032

0 commit comments

Comments
 (0)