Skip to content

Commit

Permalink
fix canvas refresh
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@15249 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 23, 2011
1 parent f9094f5 commit c41d2e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
27 changes: 14 additions & 13 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -78,8 +78,10 @@ class QgsMapCanvas::CanvasProperties


QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
: QGraphicsView( parent ),
mCanvasProperties( new CanvasProperties )
: QGraphicsView( parent )
, mCanvasProperties( new CanvasProperties )
, mPainting( false )
, mLastSize( QSize() )
{
mScene = new QGraphicsScene();
setScene( mScene );
Expand Down Expand Up @@ -943,13 +945,10 @@ void QgsMapCanvas::paintEvent( QPaintEvent *e )
{
if ( mNewSize.isValid() )
{
static bool isAlreadyIn = false;
static QSize lastSize = QSize();

lastSize = mNewSize;
mLastSize = mNewSize;
mNewSize = QSize();

if ( isAlreadyIn || mDrawing )
if ( mPainting || mDrawing )
{
//cancel current render progress
if ( mMapRenderer )
Expand All @@ -962,13 +961,14 @@ void QgsMapCanvas::paintEvent( QPaintEvent *e )
}
return;
}
isAlreadyIn = true;

while ( lastSize.isValid() )
mPainting = true;

while ( mLastSize.isValid() )
{
int width = lastSize.width();
int height = lastSize.height();
lastSize = QSize();
int width = mLastSize.width();
int height = mLastSize.height();
mLastSize = QSize();

//set map size before scene size helps keep scene indexes updated properly
// this was the cause of rubberband artifacts
Expand All @@ -984,7 +984,8 @@ void QgsMapCanvas::paintEvent( QPaintEvent *e )

emit extentsChanged();
}
isAlreadyIn = false;

mPainting = false;
}

QGraphicsView::paintEvent( e );
Expand Down
6 changes: 5 additions & 1 deletion src/gui/qgsmapcanvas.h
Expand Up @@ -77,7 +77,6 @@ class GUI_EXPORT QgsMapCanvasLayer
const QgsMapLayer* layer() const { return mLayer; }

private:

QgsMapLayer* mLayer;

/** Flag whether layer is visible */
Expand Down Expand Up @@ -461,6 +460,11 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! resize canvas size
QSize mNewSize;

//! currently in paint event
bool mPainting;

//! size of last resize event
QSize mLastSize;
}; // class QgsMapCanvas


Expand Down

0 comments on commit c41d2e6

Please sign in to comment.