Skip to content

Commit

Permalink
debug output for QgsRelation::isValid()
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Aug 11, 2016
1 parent a72485c commit 6e86a9a
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions src/core/qgsrelation.cpp
Expand Up @@ -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.