Skip to content

Commit 6e86a9a

Browse files
committedAug 11, 2016
debug output for QgsRelation::isValid()
1 parent a72485c commit 6e86a9a

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed
 

‎src/core/qgsrelation.cpp

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,26 +311,46 @@ void QgsRelation::updateRelationStatus()
311311
mValid = true;
312312

313313
if ( mRelationId.isEmpty() )
314-
mValid = false;
315-
316-
if ( !mReferencedLayer || !mReferencingLayer )
317314
{
315+
QgsDebugMsg( "Invalid relation: no ID" );
318316
mValid = false;
319-
}
317+
}
320318
else
321319
{
322-
if ( mFieldPairs.count() < 1 )
320+
if ( !mReferencedLayer )
323321
{
322+
QgsDebugMsg( QString("Invalid relation: referenced layer does not exist. ID: %1").arg(mReferencedLayerId) );
324323
mValid = false;
325324
}
326-
327-
Q_FOREACH ( const FieldPair& fieldPair, mFieldPairs )
325+
else if ( !mReferencingLayer )
328326
{
329-
if ( -1 == mReferencingLayer->fieldNameIndex( fieldPair.first )
330-
|| -1 == mReferencedLayer->fieldNameIndex( fieldPair.second ) )
327+
QgsDebugMsg( QString("Invalid relation: referencing layer does not exist. ID: %2").arg(mReferencingLayerId) );
328+
mValid = false;
329+
}
330+
else
331+
{
332+
if ( mFieldPairs.count() < 1 )
331333
{
334+
QgsDebugMsg( "Invalid relation: no pair of field is specified." );
332335
mValid = false;
333336
}
337+
338+
Q_FOREACH ( const FieldPair& fieldPair, mFieldPairs )
339+
{
340+
if ( -1 == mReferencingLayer->fieldNameIndex( fieldPair.first ))
341+
{
342+
QgsDebugMsg( QString("Invalid relation: field %1 does not exist in referencing layer %2").arg(fieldPair.first, mReferencingLayer->name()) );
343+
mValid = false;
344+
break;
345+
}
346+
else if ( -1 == mReferencedLayer->fieldNameIndex( fieldPair.second ) )
347+
{
348+
QgsDebugMsg( QString("Invalid relation: field %1 does not exist in referencedg layer %2").arg(fieldPair.second, mReferencedLayer->name()) );
349+
mValid = false;
350+
break;
351+
}
352+
}
334353
}
354+
335355
}
336356
}

0 commit comments

Comments
 (0)
Please sign in to comment.