diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/qml/jsruntime/qv4profiling.cpp | 1 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4profiling_p.h | 30 |
2 files changed, 25 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4profiling.cpp b/src/qml/jsruntime/qv4profiling.cpp index db33cd27f9..ed0dba1809 100644 --- a/src/qml/jsruntime/qv4profiling.cpp +++ b/src/qml/jsruntime/qv4profiling.cpp @@ -63,6 +63,7 @@ void Profiler::reportData() for (const FunctionCall &call : std::as_const(m_data)) { properties.append(call.properties()); Function *function = call.function(); + Q_ASSERT(function); SentMarker &marker = m_sentLocations[reinterpret_cast<quintptr>(function)]; if (!marker.isValid()) { FunctionLocation &location = locations[properties.constLast().id]; diff --git a/src/qml/jsruntime/qv4profiling_p.h b/src/qml/jsruntime/qv4profiling_p.h index 61937e85ab..6fdd457f9d 100644 --- a/src/qml/jsruntime/qv4profiling_p.h +++ b/src/qml/jsruntime/qv4profiling_p.h @@ -102,9 +102,7 @@ struct MemoryAllocationProperties { class FunctionCall { public: - - FunctionCall() : m_function(nullptr), m_start(0), m_end(0) - { Q_ASSERT_X(false, Q_FUNC_INFO, "Cannot construct a function call without function"); } + FunctionCall() : m_function(nullptr), m_start(0), m_end(0) {} FunctionCall(Function *function, qint64 start, qint64 end) : m_function(function), m_start(start), m_end(end) @@ -114,13 +112,24 @@ public: m_function(other.m_function), m_start(other.m_start), m_end(other.m_end) { m_function->executableCompilationUnit()->addref(); } + FunctionCall(FunctionCall &&other) noexcept + : m_function(std::exchange(other.m_function, nullptr)) + , m_start(std::exchange(other.m_start, 0)) + , m_end(std::exchange(other.m_end, 0)) + {} + ~FunctionCall() - { m_function->executableCompilationUnit()->release(); } + { + if (m_function) + m_function->executableCompilationUnit()->release(); + } FunctionCall &operator=(const FunctionCall &other) { if (&other != this) { - other.m_function->executableCompilationUnit()->addref(); - m_function->executableCompilationUnit()->release(); + if (other.m_function) + other.m_function->executableCompilationUnit()->addref(); + if (m_function) + m_function->executableCompilationUnit()->release(); m_function = other.m_function; m_start = other.m_start; m_end = other.m_end; @@ -128,6 +137,15 @@ public: return *this; } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(FunctionCall) + + void swap(FunctionCall &other) noexcept + { + qt_ptr_swap(m_function, other.m_function); + std::swap(m_start, other.m_start); + std::swap(m_end, other.m_end); + } + Function *function() const { return m_function; |
