aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/debugger
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2017-11-08 15:58:25 +0100
committerUlf Hermann <ulf.hermann@qt.io>2017-11-11 08:30:19 +0000
commit85fc49612816dcfc81c9dc265b146b0b90b0f184 (patch)
tree0dad538dfa59da78201219e82c5d60a0bf1866bc /src/qml/debugger
parent853b4b08d54f70d04d371d707e50760ffecf2f77 (diff)
Prevent crashes when profiling translation bindings
The m_v4Function member can now be a nullptr, which means we cannot use it as ID and we cannot retrieve the source location from it. Change-Id: Ibb49a3e68cf961f9ffe2a83b2a0b83f7d04e149e Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/debugger')
-rw-r--r--src/qml/debugger/qqmlprofiler_p.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/qml/debugger/qqmlprofiler_p.h b/src/qml/debugger/qqmlprofiler_p.h
index 88f8e94f25..6dc9859295 100644
--- a/src/qml/debugger/qqmlprofiler_p.h
+++ b/src/qml/debugger/qqmlprofiler_p.h
@@ -237,14 +237,19 @@ public:
// Add 1 to the ID, to make it different from the IDs the V4 profiler produces. The +1 makes
// the pointer point into the middle of the QV4::Function. Thus it still points to valid
// memory but we cannot accidentally create a duplicate key from another object.
- quintptr locationId(id(function) + 1);
+ // If there is no function, use a static but valid address: The profiler itself.
+ quintptr locationId = function ? id(function) + 1 : id(this);
m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(),
(1 << RangeStart | 1 << RangeLocation), Binding,
locationId));
RefLocation &location = m_locations[locationId];
- if (!location.isValid())
- location = RefLocation(function);
+ if (!location.isValid()) {
+ if (function)
+ location = RefLocation(function);
+ else // Make it valid without actually providing a location
+ location.locationType = Binding;
+ }
}
// Have toByteArrays() construct another RangeData event from the same QString later.