summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2023-04-18 08:54:36 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2023-04-18 13:23:48 +0200
commitcb30e45b9a800c6ad9cdfb446a20b6a6e8efbe71 (patch)
tree19d8fd46e458261e936d3c576c8c60e7a73560ba /src/widgets
parent2b908ba8f40924abded15681cf3b4af6056c3050 (diff)
Avoid capturing same property twice
Avoid capturing the same property multiple times in a binding by storing them in the BindingEvaluationState. We store them in a QVarLengthArray array, as the number of properties involved in a binding is expected to be rather low, so a linear scan is fine. Avoiding double capture is a good idea in general, as we would otherwise needlessly reevaluate bindings multiple times, and also needlessly allocate memory for further observers, instead of using a binding's inline observer array. Even more importantantly, our notification code makes assumptions that notify will visit bindings only exactly once. Not upholding that invariant leads to memory corruption and subsequent crashes, as observers allocated by the binding would get freed, even though we would still access them later. Fixes: QTBUG-112822 Pick-to: 6.5 6.2 Change-Id: Icdc1f43fe554df6fa69e881872b2c429d5fa0bbc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/widgets')
0 files changed, 0 insertions, 0 deletions