Skip to content
Permalink
Browse files

debug output for QgsRelation::isValid()

  • Loading branch information
3nids committed Aug 11, 2016
1 parent a72485c commit 6e86a9a0f7f04b3c8282a33068bcc19ccf921dab
Showing with 29 additions and 9 deletions.
  1. +29 −9 src/core/qgsrelation.cpp
@@ -311,26 +311,46 @@ void QgsRelation::updateRelationStatus()
mValid = true;

if ( mRelationId.isEmpty() )
mValid = false;

if ( !mReferencedLayer || !mReferencingLayer )
{
QgsDebugMsg( "Invalid relation: no ID" );
mValid = false;
}
}
else
{
if ( mFieldPairs.count() < 1 )
if ( !mReferencedLayer )
{
QgsDebugMsg( QString("Invalid relation: referenced layer does not exist. ID: %1").arg(mReferencedLayerId) );
mValid = false;
}

Q_FOREACH ( const FieldPair& fieldPair, mFieldPairs )
else if ( !mReferencingLayer )
{
if ( -1 == mReferencingLayer->fieldNameIndex( fieldPair.first )
|| -1 == mReferencedLayer->fieldNameIndex( fieldPair.second ) )
QgsDebugMsg( QString("Invalid relation: referencing layer does not exist. ID: %2").arg(mReferencingLayerId) );
mValid = false;
}
else
{
if ( mFieldPairs.count() < 1 )
{
QgsDebugMsg( "Invalid relation: no pair of field is specified." );
mValid = false;
}

Q_FOREACH ( const FieldPair& fieldPair, mFieldPairs )
{
if ( -1 == mReferencingLayer->fieldNameIndex( fieldPair.first ))
{
QgsDebugMsg( QString("Invalid relation: field %1 does not exist in referencing layer %2").arg(fieldPair.first, mReferencingLayer->name()) );
mValid = false;
break;
}
else if ( -1 == mReferencedLayer->fieldNameIndex( fieldPair.second ) )
{
QgsDebugMsg( QString("Invalid relation: field %1 does not exist in referencedg layer %2").arg(fieldPair.second, mReferencedLayer->name()) );
mValid = false;
break;
}
}
}

}
}

0 comments on commit 6e86a9a

Please sign in to comment.
You can’t perform that action at this time.