aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/data/valueTypeReference.qml
blob: a87f88ecf98f1fb04a8f578d9d0b1f297ef2b600 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
pragma ValueTypeBehavior: Reference, Inaddressable
import QtQml

QtObject {
    id: root

    property list<double> numbers: {
        var result = [];
        for (var i = 0; i < 10; ++i)
            result[i] = i;
        return result;
    }

    property rect r: ({x: 1, y: 2, width: 3, height: 4})

    function evil() : double {
        var numbers = root.numbers;
        root.numbers = [];
        var a = 0;
        for (var j = 0; j < 10; ++j) {
            a += numbers[j];
        }
        return a;
    }

    function fvil() : double {
        var r = root.r;
        root.r = {x: 5, y: 6, width: 7, height: 8};
        return r.x;
    }

    property double e: evil()
    property double f: fvil()
}