Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- fix #7926 #776

Merged
merged 1 commit into from Jul 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/composer/qgscomposition.cpp
Expand Up @@ -2014,6 +2014,7 @@ QImage QgsComposition::printPageAsRaster( int page )
image.fill( 0 );
QPainter imagePainter( &image );
renderPage( &imagePainter, page );
if ( !imagePainter.isActive() ) return QImage();
}
return image;
}
Expand Down
14 changes: 14 additions & 0 deletions src/core/qgsmaprenderer.cpp
Expand Up @@ -463,6 +463,13 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
QgsDebugMsg( "Caching enabled but layer redraw forced by extent change or empty cache" );
QImage * mypImage = new QImage( mRenderContext.painter()->device()->width(),
mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );
if ( mypImage->isNull() )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we tell the user that it's a memory issue? I don't like the idea of just not doing anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 30/07/2013 00:57, Nathan Woodrow wrote:

In src/core/qgsmaprenderer.cpp:

@@ -463,6 +463,13 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
QgsDebugMsg( "Caching enabled but layer redraw forced by extent change or empty cache" );
QImage * mypImage = new QImage( mRenderContext.painter()->device()->width(),
mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );

  •        if ( mypImage->isNull() )
    

Should we tell the user that it's a memory issue? I don't like the
idea of just not doing anything.


Reply to this email directly or view it on GitHub
https://github.com/qgis/Quantum-GIS/pull/776/files#r5464414.

The message the user will get is "Memory Allocation Error" from
src/app/qgscomposer.cpp. I agree that the error message should be
created where the error is detected, but I couldn't find any error
handling mechanism in the maprenderer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 30/07/2013 08:22, Nathan Woodrow wrote:

In src/core/qgsmaprenderer.cpp:

@@ -463,6 +463,13 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
QgsDebugMsg( "Caching enabled but layer redraw forced by extent change or empty cache" );
QImage * mypImage = new QImage( mRenderContext.painter()->device()->width(),
mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );

  •        if ( mypImage->isNull() )
    

Do you mean this
https://github.com/qgis/Quantum-GIS/blob/master/src/app/composer/qgscomposer.cpp#L978?


Reply to this email directly or view it on GitHub
https://github.com/qgis/Quantum-GIS/pull/776/files#r5469270.

Yes, this one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that's fine. We should really change that into a message bar error rather then a message box but that is not part of this pull request.

{
QgsDebugMsg( "insufficient memory for image " + QString::number(mRenderContext.painter()->device()->width()) + "x" + QString::number(mRenderContext.painter()->device()->height()) );
emit drawError( ml );
painter->end(); // drawError is not caught by anyone, so we end painting to notify caller
return;
}
mypImage->fill( 0 );
ml->setCacheImage( mypImage ); //no need to delete the old one, maplayer does it for you
QPainter * mypPainter = new QPainter( ml->cacheImage() );
Expand Down Expand Up @@ -501,6 +508,13 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
flattenedLayer = true;
mypFlattenedImage = new QImage( mRenderContext.painter()->device()->width(),
mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );
if ( mypFlattenedImage->isNull() )
{
QgsDebugMsg( "insufficient memory for image " + QString::number(mRenderContext.painter()->device()->width()) + "x" + QString::number(mRenderContext.painter()->device()->height()) );
emit drawError( ml );
painter->end(); // drawError is not caught by anyone, so we end painting to notify caller
return;
}
mypFlattenedImage->fill( 0 );
QPainter * mypPainter = new QPainter( mypFlattenedImage );
if ( mySettings.value( "/qgis/enable_anti_aliasing", true ).toBool() )
Expand Down