Skip to content
Permalink
Browse files
map canvas: delay paint event 500ms on resize (fixes #2798)
  • Loading branch information
jef-n committed Feb 8, 2014
1 parent 56bebb1 commit 00f623614a786364cb71232dbbcb3051c0d81581
Showing with 9 additions and 1 deletion.
  1. +7 −1 src/gui/qgsmapcanvas.cpp
  2. +2 −0 src/gui/qgsmapcanvas.h
@@ -116,6 +116,9 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
connect( mMapRenderer, SIGNAL( datumTransformInfoRequested( const QgsMapLayer*, const QString&, const QString& ) ),
this, SLOT( getDatumTransformInfo( const QgsMapLayer*, const QString& , const QString& ) ) );

mResizeTimer = new QTimer( this );
connect( mResizeTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );

// create map canvas item which will show the map
mMap = new QgsMapCanvasMap( this );
mScene->addItem( mMap );
@@ -377,6 +380,8 @@ QgsMapLayer* QgsMapCanvas::currentLayer()

void QgsMapCanvas::refresh()
{
mResizeTimer->stop();

// we can't draw again if already drawing...
if ( mDrawing )
return;
@@ -1033,13 +1038,14 @@ void QgsMapCanvas::mouseReleaseEvent( QMouseEvent * e )
void QgsMapCanvas::resizeEvent( QResizeEvent * e )
{
mNewSize = e->size();
mResizeTimer->start( 500 );
}

void QgsMapCanvas::paintEvent( QPaintEvent *e )
{
if ( mNewSize.isValid() )
{
if ( mPainting || mDrawing )
if ( mPainting || mDrawing || mResizeTimer->isActive() )
{
//cancel current render progress
if ( mMapRenderer )
@@ -497,6 +497,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView

//! indicates whether antialiasing will be used for rendering
bool mAntiAliasing;

QTimer *mResizeTimer;
}; // class QgsMapCanvas


0 comments on commit 00f6236

Please sign in to comment.