Skip to content

Commit

Permalink
Merge pull request #8899 from mhugo/release-3_4
Browse files Browse the repository at this point in the history
3.4 backports
  • Loading branch information
Hugo Mercier authored Jan 18, 2019
2 parents d3c04c2 + f99a911 commit 7364406
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/vertextool/qgsvertextool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,15 +980,17 @@ void QgsVertexTool::keyPressEvent( QKeyEvent *e )

QgsGeometry QgsVertexTool::cachedGeometry( const QgsVectorLayer *layer, QgsFeatureId fid )
{
if ( !mCache.contains( layer ) )
const bool layerWasNotInCache = !mCache.contains( layer );
// insert if it was not in cache
QHash<QgsFeatureId, QgsGeometry>& layerCache = mCache[layer];
if ( layerWasNotInCache )
{
connect( layer, &QgsVectorLayer::geometryChanged, this, &QgsVertexTool::onCachedGeometryChanged );
connect( layer, &QgsVectorLayer::featureDeleted, this, &QgsVertexTool::onCachedGeometryDeleted );
connect( layer, &QgsVectorLayer::willBeDeleted, this, &QgsVertexTool::clearGeometryCache );
connect( layer, &QgsVectorLayer::dataChanged, this, &QgsVertexTool::clearGeometryCache );
}

QHash<QgsFeatureId, QgsGeometry> &layerCache = mCache[layer];
if ( !layerCache.contains( fid ) )
{
QgsFeature f;
Expand All @@ -1008,6 +1010,10 @@ void QgsVertexTool::clearGeometryCache()
{
const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( sender() );
mCache.remove( layer );
disconnect( layer, &QgsVectorLayer::geometryChanged, this, &QgsVertexTool::onCachedGeometryChanged );
disconnect( layer, &QgsVectorLayer::featureDeleted, this, &QgsVertexTool::onCachedGeometryDeleted );
disconnect( layer, &QgsVectorLayer::willBeDeleted, this, &QgsVertexTool::clearGeometryCache );
disconnect( layer, &QgsVectorLayer::dataChanged, this, &QgsVertexTool::clearGeometryCache );
}

void QgsVertexTool::onCachedGeometryChanged( QgsFeatureId fid, const QgsGeometry &geom )
Expand Down
5 changes: 5 additions & 0 deletions src/providers/postgres/qgspostgresconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,8 @@ PGresult *QgsPostgresConn::PQexec( const QString &query, bool logError ) const

bool QgsPostgresConn::openCursor( const QString &cursorName, const QString &sql )
{
QMutexLocker locker( &mLock ); // to protect access to mOpenCursors

if ( mOpenCursors++ == 0 && !mTransaction )
{
QgsDebugMsgLevel( QStringLiteral( "Starting read-only transaction: %1" ).arg( mPostgresqlVersion ), 4 );
Expand All @@ -1119,6 +1121,8 @@ bool QgsPostgresConn::openCursor( const QString &cursorName, const QString &sql

bool QgsPostgresConn::closeCursor( const QString &cursorName )
{
QMutexLocker locker( &mLock ); // to protect access to mOpenCursors

if ( !PQexecNR( QStringLiteral( "CLOSE %1" ).arg( cursorName ) ) )
return false;

Expand All @@ -1133,6 +1137,7 @@ bool QgsPostgresConn::closeCursor( const QString &cursorName )

QString QgsPostgresConn::uniqueCursorName()
{
QMutexLocker locker( &mLock ); // to protect access to mNextCursorId
return QStringLiteral( "qgis_%1" ).arg( ++mNextCursorId );
}

Expand Down

0 comments on commit 7364406

Please sign in to comment.