Skip to content

Commit aa0a17b

Browse files
committedJun 22, 2013
Merge pull request #670 from tqhien/master
Fix #7927 : Add a warning message if trying to print a composition
2 parents f8d6e32 + bed65cb commit aa0a17b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎src/app/composer/qgscomposer.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ void QgsComposer::on_mActionExportAsImage_triggered()
940940
// Image size
941941
int width = ( int )( mComposition->printResolution() * mComposition->paperWidth() / 25.4 );
942942
int height = ( int )( mComposition-> printResolution() * mComposition->paperHeight() / 25.4 );
943+
int dpi = ( int )( mComposition->printResolution() );
943944

944945
int memuse = width * height * 3 / 1000000; // pixmap + image
945946
QgsDebugMsg( QString( "Image %1x%2" ).arg( width ).arg( height ) );
@@ -972,6 +973,17 @@ void QgsComposer::on_mActionExportAsImage_triggered()
972973
for ( int i = 0; i < mComposition->numPages(); ++i )
973974
{
974975
QImage image = mComposition->printPageAsRaster( i );
976+
if (image.isNull())
977+
{
978+
QMessageBox::warning( 0, tr( "Memory Allocation Error" ),
979+
tr( "Trying to create image #%1 ( %2x%3 @ %4dpi )"
980+
"may result in a memory overflow.\n"
981+
"Please try a lower resolution or a smaller papersize" )
982+
.arg( i+1 ).arg( width ).arg( height ).arg ( dpi ),
983+
QMessageBox::Ok , QMessageBox::Ok );
984+
mView->setPaintingEnabled( true );
985+
return;
986+
}
975987
if ( i == 0 )
976988
{
977989
image.save( fileNExt.first, fileNExt.second.toLocal8Bit().constData() );

0 commit comments

Comments
 (0)
Please sign in to comment.