Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix canvas refresh to avoid crashes
git-svn-id: http://svn.osgeo.org/qgis/trunk@15254 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
brushtyler committed Feb 23, 2011
1 parent 26cc17c commit 158266d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 6 additions & 10 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -81,7 +81,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
: QGraphicsView( parent )
, mCanvasProperties( new CanvasProperties )
, mPainting( false )
, mLastSize( QSize() )
, mNewSize( QSize() )
{
mScene = new QGraphicsScene();
setScene( mScene );
Expand Down Expand Up @@ -945,9 +945,6 @@ void QgsMapCanvas::paintEvent( QPaintEvent *e )
{
if ( mNewSize.isValid() )
{
mLastSize = mNewSize;
mNewSize = QSize();

if ( mPainting || mDrawing )
{
//cancel current render progress
Expand All @@ -964,16 +961,15 @@ void QgsMapCanvas::paintEvent( QPaintEvent *e )

mPainting = true;

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

//set map size before scene size helps keep scene indexes updated properly
// this was the cause of rubberband artifacts
mMap->resize( QSize( width, height ) );
mScene->setSceneRect( QRectF( 0, 0, width, height ) );
mMap->resize( lastSize );
mScene->setSceneRect( QRectF( 0, 0, lastSize.width(), lastSize.height() ) );

// notify canvas items of change
updateCanvasItemPositions();
Expand Down
2 changes: 0 additions & 2 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -463,8 +463,6 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! currently in paint event
bool mPainting;

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


Expand Down

0 comments on commit 158266d

Please sign in to comment.