From ff182d1c97b562c3975cb2dfdf1ed938fc2fd9f7 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 9 Jan 2018 17:07:53 +0100 Subject: [PATCH] QmlProfiler: Guard state widget against unexpected deletion order If the model manager or the state manager disappear before the parent widget, we might still get a timer update in between. Change-Id: I6a67868615ef9d570e2ce438d9d9bd88b1035cc2 Reviewed-by: hjk --- src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp b/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp index 0652a0258c5..c866f9e6ee9 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp @@ -35,6 +35,7 @@ #include #include #include +#include namespace QmlProfiler { namespace Internal { @@ -46,8 +47,8 @@ class QmlProfilerStateWidget::QmlProfilerStateWidgetPrivate QLabel *text; - QmlProfilerStateManager *m_profilerState; - QmlProfilerModelManager *m_modelManager; + QPointer m_profilerState; + QPointer m_modelManager; QTimer timer; }; @@ -106,6 +107,12 @@ void QmlProfilerStateWidget::showText(const QString &text) void QmlProfilerStateWidget::updateDisplay() { + if (!d->m_modelManager || !d->m_profilerState) { + d->timer.stop(); + setVisible(false); + return; + } + // When application is being profiled if (d->m_profilerState->serverRecording()) { // Heuristic to not show the number if the application will only send the events when it @@ -156,7 +163,8 @@ void QmlProfilerStateWidget::updateDisplay() void QmlProfilerStateWidget::update() { - QmlProfilerModelManager::State state = d->m_modelManager->state(); + QmlProfilerModelManager::State state = d->m_modelManager ? d->m_modelManager->state() + : QmlProfilerModelManager::Empty; if (state == QmlProfilerModelManager::AcquiringData || state == QmlProfilerModelManager::ProcessingData) { d->timer.start();