Merge lp:~marcustomlinson/unity-js-scopes/lp-1543059 into lp:unity-js-scopes

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Alexandre Abreu
Approved revision: 128
Merged at revision: 128
Proposed branch: lp:~marcustomlinson/unity-js-scopes/lp-1543059
Merge into: lp:unity-js-scopes
Diff against target: 45 lines (+22/-11)
1 file modified
src/bindings/src/preview-widget.cc (+22/-11)
To merge this branch: bzr merge lp:~marcustomlinson/unity-js-scopes/lp-1543059
Reviewer Review Type Date Requested Status
Alexandre Abreu (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+285679@code.launchpad.net

Commit message

Deal with non-dict types for variant arrays in PreviewWidget::add_attribute_value()

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandre Abreu (abreu-alexandre) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/bindings/src/preview-widget.cc'
2--- src/bindings/src/preview-widget.cc 2016-02-04 10:12:41 +0000
3+++ src/bindings/src/preview-widget.cc 2016-02-11 05:19:56 +0000
4@@ -89,19 +89,30 @@
5 if (v.which() == unity::scopes::Variant::Array) {
6 unity::scopes::VariantArray va = v.get_array();
7
8- for (auto &d : va) {
9- if (d.which() == unity::scopes::Variant::Dict) {
10- unity::scopes::VariantMap vm = d.get_dict();
11- std::vector<std::pair<std::string, unity::scopes::Variant>> t;
12-
13- for (auto &c : vm) {
14- t.push_back({c.first, c.second});
15+ if (va.empty())
16+ {
17+ return;
18+ }
19+ else if (va.front().which() == unity::scopes::Variant::Dict)
20+ {
21+ for (auto &d : va) {
22+ if (d.which() == unity::scopes::Variant::Dict) {
23+ unity::scopes::VariantMap vm = d.get_dict();
24+ std::vector<std::pair<std::string, unity::scopes::Variant>> t;
25+
26+ for (auto &c : vm) {
27+ t.push_back({c.first, c.second});
28+ }
29+
30+ vb.add_tuple(t);
31 }
32-
33- vb.add_tuple(t);
34 }
35- }
36- preview_widget_->add_attribute_value(key, vb.end());
37+ preview_widget_->add_attribute_value(key, vb.end());
38+ }
39+ else
40+ {
41+ preview_widget_->add_attribute_value(key, v);
42+ }
43 }
44 else if (v.which() == unity::scopes::Variant::Dict) {
45 unity::scopes::VariantMap vm = v.get_dict();

Subscribers

People subscribed via source and target branches

to all changes: