-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 nlohman::json array list initializer broken on GCC #31293
Conversation
the issue: json j { something_returning_json_array_of_values() }; produces a json::array( json::array( values ) ) ) instead of json::array( values ) by using the assignment all is fine: json j = something_returning_json_array_of_values(); produces a json::array( values ) as expected
@m-kuhn I think you've already seen this this bug recently. |
src/core/qgsjsonutils.cpp
Outdated
@@ -238,7 +238,7 @@ json QgsJsonExporter::exportFeaturesToJsonObject( const QgsFeatureList &features | |||
const auto constFeatures = features; | |||
for ( const QgsFeature &feature : constFeatures ) | |||
{ | |||
data["features"].push_back( exportFeatureToJsonObject( feature ) ); | |||
data[ "features" ].push_back( exportFeatureToJsonObject( feature ) ); |
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.
Since this is a cosmetic one, can you use QStringLiteral on "features" and drop 238 in favor of qgis::as_const
? ;)
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.
no literal here, it's a std::strings, ok for the as_const
@signedav you looked into it in more detail, what do you think? |
I confirm what @elpaso writes regarding the json. Like the observation I made during debugging and wrote down here #30758:
|
@signedav just to be sure, which compiler are you using? Because I was not able to reproduce this on clang, but only on GCC. |
GCC as well. |
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_8
# 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 3924625b9bd98186ec242c3541a075baeb5494e7 5549a4e397d026263cf012c1c9d7c5b998a93d49 69b1ba5c8364b578d1966bb8671e87648814abda
# Create a new branch with these backported commits.
git checkout -b backport-31293-to-release-3_8
# Push it to GitHub.
git push --set-upstream origin backport-31293-to-release-3_8
# Go back to the original working tree.
cd ../..
# Delete the working tree.
git worktree remove .worktrees/backport Then, create a pull request where the |
no need to backport |
the issue:
json j { something_returning_json_array_of_values() };
produces a
json::array( json::array( values ) ) )
instead of
json::array( values )
by using the assignment all is fine:
json j = something_returning_json_array_of_values();
produces a
json::array( values )
as expected