Merge pull request #670 from tqhien/master

Fix #7927 : Add a warning message if trying to print a composition
This commit is contained in:
mhugent 2013-06-22 00:22:25 -07:00
commit aa0a17b253

View File

@ -940,6 +940,7 @@ void QgsComposer::on_mActionExportAsImage_triggered()
// Image size
int width = ( int )( mComposition->printResolution() * mComposition->paperWidth() / 25.4 );
int height = ( int )( mComposition-> printResolution() * mComposition->paperHeight() / 25.4 );
int dpi = ( int )( mComposition->printResolution() );
int memuse = width * height * 3 / 1000000; // pixmap + image
QgsDebugMsg( QString( "Image %1x%2" ).arg( width ).arg( height ) );
@ -972,6 +973,17 @@ void QgsComposer::on_mActionExportAsImage_triggered()
for ( int i = 0; i < mComposition->numPages(); ++i )
{
QImage image = mComposition->printPageAsRaster( i );
if (image.isNull())
{
QMessageBox::warning( 0, tr( "Memory Allocation Error" ),
tr( "Trying to create image #%1 ( %2x%3 @ %4dpi )"
"may result in a memory overflow.\n"
"Please try a lower resolution or a smaller papersize" )
.arg( i+1 ).arg( width ).arg( height ).arg ( dpi ),
QMessageBox::Ok , QMessageBox::Ok );
mView->setPaintingEnabled( true );
return;
}
if ( i == 0 )
{
image.save( fileNExt.first, fileNExt.second.toLocal8Bit().constData() );