forked from qt-creator/qt-creator
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 <hjk@qt.io>
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <QTime>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QPointer>
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
@@ -46,8 +47,8 @@ class QmlProfilerStateWidget::QmlProfilerStateWidgetPrivate
|
||||
|
||||
QLabel *text;
|
||||
|
||||
QmlProfilerStateManager *m_profilerState;
|
||||
QmlProfilerModelManager *m_modelManager;
|
||||
QPointer<QmlProfilerStateManager> m_profilerState;
|
||||
QPointer<QmlProfilerModelManager> 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();
|
||||
|
Reference in New Issue
Block a user