forked from qt-creator/qt-creator
QmlProfiler: Delay creation of views until activation
We don't need to waste the time and memory required to create the views if they are never shown. Change-Id: I56add08981c90263e6735f5b7e6fac2140b457e4 Fixes: QTCREATORBUG-21894 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -51,6 +51,12 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
||||
QTC_ASSERT(m_profilerModelManager, return);
|
||||
QTC_ASSERT(m_profilerState, return);
|
||||
|
||||
m_perspective = new Utils::Perspective(Constants::QmlProfilerPerspectiveId, tr("QML Profiler"));
|
||||
m_perspective->setAboutToActivateCallback([this]() { createViews(); });
|
||||
}
|
||||
|
||||
void QmlProfilerViewManager::createViews()
|
||||
{
|
||||
m_traceView = new QmlProfilerTraceView(nullptr, this, m_profilerModelManager);
|
||||
connect(m_traceView, &QmlProfilerTraceView::gotoSourceLocation,
|
||||
this, &QmlProfilerViewManager::gotoSourceLocation);
|
||||
@@ -61,8 +67,6 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
||||
|
||||
new QmlProfilerStateWidget(m_profilerState, m_profilerModelManager, m_traceView);
|
||||
|
||||
m_perspective = new Utils::Perspective(Constants::QmlProfilerPerspectiveId, tr("QML Profiler"));
|
||||
|
||||
auto prepareEventsView = [this](QmlProfilerEventsView *view) {
|
||||
connect(view, &QmlProfilerEventsView::typeSelected,
|
||||
this, &QmlProfilerViewManager::typeSelected);
|
||||
@@ -93,6 +97,8 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
||||
}
|
||||
m_perspective->addWindow(m_statisticsView, Perspective::AddToTab, anchorDock);
|
||||
m_perspective->addWindow(anchorDock, Perspective::Raise, nullptr);
|
||||
m_perspective->setAboutToActivateCallback(Perspective::Callback());
|
||||
emit viewsCreated();
|
||||
}
|
||||
|
||||
QmlProfilerViewManager::~QmlProfilerViewManager()
|
||||
@@ -105,7 +111,8 @@ QmlProfilerViewManager::~QmlProfilerViewManager()
|
||||
|
||||
void QmlProfilerViewManager::clear()
|
||||
{
|
||||
m_traceView->clear();
|
||||
if (m_traceView)
|
||||
m_traceView->clear();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user