Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid layer in value relation field #3542

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tomasMizera
Copy link
Collaborator

It seems there is some edge-case scenario where a referenced layer in the value relation field is not available (probably a missing layer or some other project misconfiguration ... I could not reproduce it with my projects)

Logs are indicating that mTitleField is empty, thus we continue to FeaturesModel::FeatureTitle with pair->layer() as nullptr. See

QVariant ValueRelationFeaturesModel::featureTitle( const FeatureLayerPair &pair ) const
{
if ( !mTitleField.isEmpty() )
{
return pair.feature().attribute( mTitleField );
}
return FeaturesModel::featureTitle( pair );
}

See bug report logs for more details -> Fixes #3535

Copy link
Contributor

@VitorVieiraZ VitorVieiraZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good to me. There is just an issue in the code layout check.

if ( !featurePair.layer() || !featurePair.layer()->isValid() )
{
CoreUtils::log( QStringLiteral( "Features Model" ), QStringLiteral( "Received invalid feature layer pair!" ) );
return tr( "Unknown title" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When title is empty we return pair.feature().id()
Should we not be returning the same for this case too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, if the layer is invalid, I'd expect everything is broken 💥

Copy link

Pull Request Test Coverage Report for Build 10072387691

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 34 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.02%) to 59.998%

Files with Coverage Reduction New Missed Lines %
input/app/featuresmodel.h 1 0.0%
input/app/projectsmodel.cpp 1 69.17%
input/app/attributes/attributecontroller.cpp 1 77.43%
input/app/featuresmodel.cpp 31 67.79%
Totals Coverage Status
Change from base Build 9953082018: -0.02%
Covered Lines: 7699
Relevant Lines: 12832

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash at QgsVectorLayer::displayExpression()
4 participants