Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,7 @@ bool QgsVectorLayerJoinBuffer::addJoin( const QgsVectorJoinInfo& joinInfo ) | |
if ( QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( joinInfo.joinLayerId ) ) ) | ||
{ | ||
connect( vl, SIGNAL( updatedFields() ), this, SLOT( joinedLayerUpdatedFields() ), Qt::UniqueConnection ); | ||
connect( vl, SIGNAL( layerModified() ), this, SLOT( joinedLayerModified() ), Qt::UniqueConnection ); | ||
} | ||
|
||
emit joinedFieldsChanged(); | ||
|
@@ -118,7 +119,7 @@ bool QgsVectorLayerJoinBuffer::removeJoin( const QString& joinLayerId ) | |
void QgsVectorLayerJoinBuffer::cacheJoinLayer( QgsVectorJoinInfo& joinInfo ) | ||
{ | ||
//memory cache not required or already done | ||
if ( !joinInfo.memoryCache || !joinInfo.cachedAttributes.isEmpty() ) | ||
if ( !joinInfo.memoryCache || !joinInfo.cacheDirty ) | ||
{ | ||
return; | ||
} | ||
|
@@ -175,6 +176,7 @@ void QgsVectorLayerJoinBuffer::cacheJoinLayer( QgsVectorJoinInfo& joinInfo ) | |
joinInfo.cachedAttributes.insert( key, attrs2 ); | ||
} | ||
} | ||
joinInfo.cacheDirty = false; | ||
} | ||
} | ||
|
||
|
@@ -260,11 +262,15 @@ void QgsVectorLayerJoinBuffer::createJoinCaches() | |
QList< QgsVectorJoinInfo >::iterator joinIt = mVectorJoins.begin(); | ||
for ( ; joinIt != mVectorJoins.end(); ++joinIt ) | ||
{ | ||
cacheJoinLayer( *joinIt ); | ||
if ( joinIt->memoryCache && joinIt->cacheDirty ) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
3nids
Member
|
||
cacheJoinLayer( *joinIt ); | ||
|
||
// make sure we are connected to the joined layer | ||
if ( QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( joinIt->joinLayerId ) ) ) | ||
{ | ||
connect( vl, SIGNAL( updatedFields() ), this, SLOT( joinedLayerUpdatedFields() ), Qt::UniqueConnection ); | ||
connect( vl, SIGNAL( layerModified() ), this, SLOT( joinedLayerModified() ), Qt::UniqueConnection ); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -329,6 +335,7 @@ void QgsVectorLayerJoinBuffer::readXml( const QDomNode& layer_node ) | |
info.joinLayerId = infoElem.attribute( "joinLayerId" ); | ||
info.targetFieldName = infoElem.attribute( "targetFieldName" ); | ||
info.memoryCache = infoElem.attribute( "memoryCache" ).toInt(); | ||
info.cacheDirty = true; | ||
|
||
info.joinFieldIndex = infoElem.attribute( "joinField" ).toInt(); //for compatibility with 1.x | ||
info.targetFieldIndex = infoElem.attribute( "targetField" ).toInt(); //for compatibility with 1.x | ||
|
@@ -397,6 +404,9 @@ QgsVectorLayerJoinBuffer* QgsVectorLayerJoinBuffer::clone() const | |
|
||
void QgsVectorLayerJoinBuffer::joinedLayerUpdatedFields() | ||
{ | ||
// TODO - check - this whole method is probably not needed anymore, | ||
// since the cache handling is covered by joinedLayerModified() | ||
|
||
QgsVectorLayer* joinedLayer = qobject_cast<QgsVectorLayer*>( sender() ); | ||
Q_ASSERT( joinedLayer ); | ||
|
||
|
@@ -412,3 +422,18 @@ void QgsVectorLayerJoinBuffer::joinedLayerUpdatedFields() | |
|
||
emit joinedFieldsChanged(); | ||
} | ||
|
||
void QgsVectorLayerJoinBuffer::joinedLayerModified() | ||
{ | ||
QgsVectorLayer* joinedLayer = qobject_cast<QgsVectorLayer*>( sender() ); | ||
Q_ASSERT( joinedLayer ); | ||
|
||
// recache the joined layer | ||
for ( QgsVectorJoinList::iterator it = mVectorJoins.begin(); it != mVectorJoins.end(); ++it ) | ||
{ | ||
if ( joinedLayer->id() == it->joinLayerId ) | ||
{ | ||
it->cacheDirty = true; | ||
} | ||
} | ||
} |
2 comments
on commit 0a5ad73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yes, finally!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second that, huge improvement for anyone dealing with joins.
I get a crash here when opening an atlas composer
here is the stacktrace
do you need further details?