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
When loading a QLR, try to match the layer name if id does not #30151
When loading a QLR, try to match the layer name if id does not #30151
Conversation
python/gui/auto_generated/editorwidgets/core/qgswidgetwrapper.sip.in
Outdated
Show resolved
Hide resolved
@@ -70,6 +71,23 @@ QVariantMap QgsValueRelationConfigDlg::config() | |||
void QgsValueRelationConfigDlg::setConfig( const QVariantMap &config ) | |||
{ | |||
QgsVectorLayer *lyr = QgsProject::instance()->mapLayer<QgsVectorLayer *>( config.value( QStringLiteral( "Layer" ) ).toString() ); | |||
// If layer is null, let's try to match it against name and provider | |||
if ( ! lyr ) |
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.
Look into QgsVectorLayerRef, and QgsMapLayerRef::resolveWeakly. It's designed to encapsulate all this logic for you.
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 looked into that, I don't think it fits here, we don't want to check for datasource and provider type, there is a strong use case for layers migrated into a DB where datasource and provided type have changed.
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.
Hmm - so we need a "resolveSuperWeakly" method?
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.
Maybe, I would probably prefer to have a template based getLayersByName and get the first element out of the results if not empty.
python/core/auto_generated/fieldformatter/qgsvaluerelationfieldformatter.sip.in
Outdated
Show resolved
Hide resolved
f9977e9
to
0328a23
Compare
0328a23
to
103ef76
Compare
Nice, I really like the latest iteration |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub.
git fetch
# Create new working tree.
git worktree add .worktrees/backport release-3_4
# Navigate to the new directory.
cd .worktrees/backport
# Cherry-pick all the commits of this pull request and resolve the likely conflicts.
git cherry-pick f02b1ee1d1199788112babd5498ee029b9e31fb9 dcc779a62d2b6126e3ff468c7d9ec0991ad0b829 f9b50b5b386ceb573b7ffbb54c0cd817d83859d9 a2957010231bc0634fda626ace16f83010fea0ba a45a82e8d744c353e23effc24c5e0ce0df3042a7 103ef762ca7247b013df61e149516e50b40e5214 fc20e31fa397da8af39dc70bd31b76121e62477f 6bd5c51dfcf1860c93565ee566156f259ca05bc0 2d45ba8d68dd6ef56c25bfb6d0e107d6435f0e9e
# Create a new branch with these backported commits.
git checkout -b backport-30151-to-release-3_4
# Push it to GitHub.
git push --set-upstream origin backport-30151-to-release-3_4
# Go back to the original working tree.
cd ../..
# Delete the working tree.
git worktree remove .worktrees/backport Then, create a pull request where the |
Fixes #30115