Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
avoid reloading not rendered layers on map refresh
  • Loading branch information
jef-n committed Jun 24, 2015
1 parent feb8d38 commit ea71b2c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
4 changes: 4 additions & 0 deletions python/gui/qgsmapcanvas.sip
Expand Up @@ -84,6 +84,10 @@ class QgsMapCanvas : QGraphicsView
//! @note added in 2.4
void clearCache();

//! Reload all layers, clear the cache and refresh the canvas
//! @note added in 2.9
void refreshAllLayers();

//! Set whether the layers are rendered in parallel or sequentially
//! @note added in 2.4
void setParallelRenderingEnabled( bool enabled );
Expand Down
7 changes: 1 addition & 6 deletions src/app/qgisapp.cpp
Expand Up @@ -6635,12 +6635,7 @@ void QgisApp::refreshMapCanvas()
//stop any current rendering
mMapCanvas->stopRendering();

//reload cached provider data
QgsMapLayerRegistry::instance()->reloadAllLayers();

mMapCanvas->clearCache();
//then refresh
mMapCanvas->refresh();
mMapCanvas->refreshAllLayers();
}

void QgisApp::canvasRefreshStarted()
Expand Down
17 changes: 17 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1966,3 +1966,20 @@ void QgsMapCanvas::enableRotation( bool enable )
{
QSettings().setValue( "/qgis/canvasRotation", enable );
}

void QgsMapCanvas::refreshAllLayers()
{
// reload all layers in canvas
for ( int i = 0; i < layerCount(); i++ )
{
QgsMapLayer *l = layer( i );
if ( l )
l->reload();
}

// clear the cache
clearCache();

// and then refresh
refresh();
}
4 changes: 4 additions & 0 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -154,6 +154,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! @note added in 2.4
void clearCache();

//! Reload all layers, clear the cache and refresh the canvas
//! @note added in 2.9
void refreshAllLayers();

//! Set whether the layers are rendered in parallel or sequentially
//! @note added in 2.4
void setParallelRenderingEnabled( bool enabled );
Expand Down

0 comments on commit ea71b2c

Please sign in to comment.