Skip to content

Commit c41d2e6

Browse files
author
jef
committed
fix canvas refresh
git-svn-id: http://svn.osgeo.org/qgis/trunk@15249 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f9094f5 commit c41d2e6

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

src/gui/qgsmapcanvas.cpp

+14-13
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ class QgsMapCanvas::CanvasProperties
7878

7979

8080
QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
81-
: QGraphicsView( parent ),
82-
mCanvasProperties( new CanvasProperties )
81+
: QGraphicsView( parent )
82+
, mCanvasProperties( new CanvasProperties )
83+
, mPainting( false )
84+
, mLastSize( QSize() )
8385
{
8486
mScene = new QGraphicsScene();
8587
setScene( mScene );
@@ -943,13 +945,10 @@ void QgsMapCanvas::paintEvent( QPaintEvent *e )
943945
{
944946
if ( mNewSize.isValid() )
945947
{
946-
static bool isAlreadyIn = false;
947-
static QSize lastSize = QSize();
948-
949-
lastSize = mNewSize;
948+
mLastSize = mNewSize;
950949
mNewSize = QSize();
951950

952-
if ( isAlreadyIn || mDrawing )
951+
if ( mPainting || mDrawing )
953952
{
954953
//cancel current render progress
955954
if ( mMapRenderer )
@@ -962,13 +961,14 @@ void QgsMapCanvas::paintEvent( QPaintEvent *e )
962961
}
963962
return;
964963
}
965-
isAlreadyIn = true;
966964

967-
while ( lastSize.isValid() )
965+
mPainting = true;
966+
967+
while ( mLastSize.isValid() )
968968
{
969-
int width = lastSize.width();
970-
int height = lastSize.height();
971-
lastSize = QSize();
969+
int width = mLastSize.width();
970+
int height = mLastSize.height();
971+
mLastSize = QSize();
972972

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

985985
emit extentsChanged();
986986
}
987-
isAlreadyIn = false;
987+
988+
mPainting = false;
988989
}
989990

990991
QGraphicsView::paintEvent( e );

src/gui/qgsmapcanvas.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class GUI_EXPORT QgsMapCanvasLayer
7777
const QgsMapLayer* layer() const { return mLayer; }
7878

7979
private:
80-
8180
QgsMapLayer* mLayer;
8281

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

463+
//! currently in paint event
464+
bool mPainting;
465+
466+
//! size of last resize event
467+
QSize mLastSize;
464468
}; // class QgsMapCanvas
465469

466470

0 commit comments

Comments
 (0)