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 nlohman::json array list initializer broken on GCC #31293

Merged
merged 3 commits into from
Aug 19, 2019

Conversation

elpaso
Copy link
Contributor

@elpaso elpaso commented Aug 19, 2019

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

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
@elpaso elpaso added backport release-3_8 Bug Either a bug report, or a bug fix. Let's hope for the latter! labels Aug 19, 2019
@elpaso
Copy link
Contributor Author

elpaso commented Aug 19, 2019

@m-kuhn I think you've already seen this this bug recently.

@@ -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 ) );
Copy link
Member

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? ;)

Copy link
Contributor Author

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

@m-kuhn
Copy link
Member

m-kuhn commented Aug 19, 2019

@signedav you looked into it in more detail, what do you think?

@signedav
Copy link
Contributor

I confirm what @elpaso writes regarding the json.

Like the observation I made during debugging and wrote down here #30758:

Apparently { QgsJsonUtils::jsonFromVariant( value ) } returns an array containing one element and that's an object while = QgsJsonUtils::jsonFromVariant( value ) contains the object itself not nested in an array.

@elpaso
Copy link
Contributor Author

elpaso commented Aug 19, 2019

@signedav just to be sure, which compiler are you using? Because I was not able to reproduce this on clang, but only on GCC.

@signedav
Copy link
Contributor

GCC as well.

@elpaso elpaso merged commit ea0b650 into qgis:master Aug 19, 2019
@elpaso elpaso deleted the json-fix-gcc-list-initialized branch August 19, 2019 12:03
@backporting
Copy link
Contributor

backporting bot commented Aug 19, 2019

The backport to release-3_8 failed:

Commits ["3924625b9bd98186ec242c3541a075baeb5494e7","5549a4e397d026263cf012c1c9d7c5b998a93d49","69b1ba5c8364b578d1966bb8671e87648814abda"] could not be cherry-picked on top of release-3_8

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 base branch is release-3_8 and the compare/head branch is backport-31293-to-release-3_8.

@elpaso
Copy link
Contributor Author

elpaso commented Aug 19, 2019

no need to backport

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants