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:
@@ -91,11 +91,7 @@ public:
|
|||||||
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
|
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||||
{
|
{
|
||||||
Q_UNUSED(arguments)
|
Q_UNUSED(arguments)
|
||||||
|
return Utils::HostOsInfo::canCreateOpenGLContext(errorString);
|
||||||
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorString))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerPlugin::extensionsInitialized()
|
void QmlProfilerPlugin::extensionsInitialized()
|
||||||
|
@@ -52,11 +52,14 @@ void QmlProfilerTextMark::addTypeId(int typeId)
|
|||||||
|
|
||||||
void QmlProfilerTextMark::paintIcon(QPainter *painter, const QRect &paintRect) const
|
void QmlProfilerTextMark::paintIcon(QPainter *painter, const QRect &paintRect) const
|
||||||
{
|
{
|
||||||
|
const QmlProfilerStatisticsView *statisticsView = m_viewManager->statisticsView();
|
||||||
|
QTC_ASSERT(statisticsView, return);
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setPen(Qt::black);
|
painter->setPen(Qt::black);
|
||||||
painter->fillRect(paintRect, Qt::white);
|
painter->fillRect(paintRect, Qt::white);
|
||||||
painter->drawRect(paintRect);
|
painter->drawRect(paintRect);
|
||||||
painter->drawText(paintRect, m_viewManager->statisticsView()->summary(m_typeIds),
|
painter->drawText(paintRect, statisticsView->summary(m_typeIds),
|
||||||
Qt::AlignRight | Qt::AlignVCenter);
|
Qt::AlignRight | Qt::AlignVCenter);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
@@ -133,10 +136,13 @@ void QmlProfilerTextMarkModel::hideTextMarks()
|
|||||||
|
|
||||||
bool QmlProfilerTextMark::addToolTipContent(QLayout *target) const
|
bool QmlProfilerTextMark::addToolTipContent(QLayout *target) const
|
||||||
{
|
{
|
||||||
|
const QmlProfilerStatisticsView *statisticsView = m_viewManager->statisticsView();
|
||||||
|
QTC_ASSERT(statisticsView, return false);
|
||||||
|
|
||||||
auto layout = new QGridLayout;
|
auto layout = new QGridLayout;
|
||||||
layout->setHorizontalSpacing(10);
|
layout->setHorizontalSpacing(10);
|
||||||
for (int row = 0, rowEnd = m_typeIds.length(); row != rowEnd; ++row) {
|
for (int row = 0, rowEnd = m_typeIds.length(); row != rowEnd; ++row) {
|
||||||
const QStringList typeDetails = m_viewManager->statisticsView()->details(m_typeIds[row]);
|
const QStringList typeDetails = statisticsView->details(m_typeIds[row]);
|
||||||
for (int column = 0, columnEnd = typeDetails.length(); column != columnEnd; ++column) {
|
for (int column = 0, columnEnd = typeDetails.length(); column != columnEnd; ++column) {
|
||||||
QLabel *label = new QLabel;
|
QLabel *label = new QLabel;
|
||||||
label->setAlignment(column == columnEnd - 1 ? Qt::AlignRight : Qt::AlignLeft);
|
label->setAlignment(column == columnEnd - 1 ? Qt::AlignRight : Qt::AlignLeft);
|
||||||
|
@@ -195,9 +195,12 @@ QmlProfilerTool::QmlProfilerTool()
|
|||||||
d->m_searchButton = new QToolButton;
|
d->m_searchButton = new QToolButton;
|
||||||
d->m_searchButton->setIcon(Utils::Icons::ZOOM_TOOLBAR.icon());
|
d->m_searchButton->setIcon(Utils::Icons::ZOOM_TOOLBAR.icon());
|
||||||
d->m_searchButton->setToolTip(tr("Search timeline event notes."));
|
d->m_searchButton->setToolTip(tr("Search timeline event notes."));
|
||||||
|
d->m_searchButton->setEnabled(false);
|
||||||
|
|
||||||
connect(d->m_searchButton, &QToolButton::clicked, this, &QmlProfilerTool::showTimeLineSearch);
|
connect(d->m_searchButton, &QToolButton::clicked, this, &QmlProfilerTool::showTimeLineSearch);
|
||||||
d->m_searchButton->setEnabled(d->m_viewContainer->traceView()->isUsable());
|
connect(d->m_viewContainer, &QmlProfilerViewManager::viewsCreated, this, [this]() {
|
||||||
|
d->m_searchButton->setEnabled(d->m_viewContainer->traceView()->isUsable());
|
||||||
|
});
|
||||||
|
|
||||||
d->m_displayFeaturesButton = new QToolButton;
|
d->m_displayFeaturesButton = new QToolButton;
|
||||||
d->m_displayFeaturesButton->setIcon(Utils::Icons::FILTER.icon());
|
d->m_displayFeaturesButton->setIcon(Utils::Icons::FILTER.icon());
|
||||||
@@ -451,6 +454,7 @@ void QmlProfilerTool::updateTimeDisplay()
|
|||||||
void QmlProfilerTool::showTimeLineSearch()
|
void QmlProfilerTool::showTimeLineSearch()
|
||||||
{
|
{
|
||||||
QmlProfilerTraceView *traceView = d->m_viewContainer->traceView();
|
QmlProfilerTraceView *traceView = d->m_viewContainer->traceView();
|
||||||
|
QTC_ASSERT(traceView, return);
|
||||||
QTC_ASSERT(qobject_cast<QDockWidget *>(traceView->parentWidget()), return);
|
QTC_ASSERT(qobject_cast<QDockWidget *>(traceView->parentWidget()), return);
|
||||||
traceView->parentWidget()->raise();
|
traceView->parentWidget()->raise();
|
||||||
traceView->setFocus();
|
traceView->setFocus();
|
||||||
@@ -482,7 +486,8 @@ void QmlProfilerTool::setButtonsEnabled(bool enable)
|
|||||||
{
|
{
|
||||||
d->m_clearButton->setEnabled(enable);
|
d->m_clearButton->setEnabled(enable);
|
||||||
d->m_displayFeaturesButton->setEnabled(enable);
|
d->m_displayFeaturesButton->setEnabled(enable);
|
||||||
d->m_searchButton->setEnabled(d->m_viewContainer->traceView()->isUsable() && enable);
|
const QmlProfilerTraceView *traceView = d->m_viewContainer->traceView();
|
||||||
|
d->m_searchButton->setEnabled(traceView && traceView->isUsable() && enable);
|
||||||
d->m_recordFeaturesMenu->setEnabled(enable);
|
d->m_recordFeaturesMenu->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,6 +51,12 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
|||||||
QTC_ASSERT(m_profilerModelManager, return);
|
QTC_ASSERT(m_profilerModelManager, return);
|
||||||
QTC_ASSERT(m_profilerState, 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);
|
m_traceView = new QmlProfilerTraceView(nullptr, this, m_profilerModelManager);
|
||||||
connect(m_traceView, &QmlProfilerTraceView::gotoSourceLocation,
|
connect(m_traceView, &QmlProfilerTraceView::gotoSourceLocation,
|
||||||
this, &QmlProfilerViewManager::gotoSourceLocation);
|
this, &QmlProfilerViewManager::gotoSourceLocation);
|
||||||
@@ -61,8 +67,6 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
|||||||
|
|
||||||
new QmlProfilerStateWidget(m_profilerState, m_profilerModelManager, m_traceView);
|
new QmlProfilerStateWidget(m_profilerState, m_profilerModelManager, m_traceView);
|
||||||
|
|
||||||
m_perspective = new Utils::Perspective(Constants::QmlProfilerPerspectiveId, tr("QML Profiler"));
|
|
||||||
|
|
||||||
auto prepareEventsView = [this](QmlProfilerEventsView *view) {
|
auto prepareEventsView = [this](QmlProfilerEventsView *view) {
|
||||||
connect(view, &QmlProfilerEventsView::typeSelected,
|
connect(view, &QmlProfilerEventsView::typeSelected,
|
||||||
this, &QmlProfilerViewManager::typeSelected);
|
this, &QmlProfilerViewManager::typeSelected);
|
||||||
@@ -93,6 +97,8 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
|||||||
}
|
}
|
||||||
m_perspective->addWindow(m_statisticsView, Perspective::AddToTab, anchorDock);
|
m_perspective->addWindow(m_statisticsView, Perspective::AddToTab, anchorDock);
|
||||||
m_perspective->addWindow(anchorDock, Perspective::Raise, nullptr);
|
m_perspective->addWindow(anchorDock, Perspective::Raise, nullptr);
|
||||||
|
m_perspective->setAboutToActivateCallback(Perspective::Callback());
|
||||||
|
emit viewsCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerViewManager::~QmlProfilerViewManager()
|
QmlProfilerViewManager::~QmlProfilerViewManager()
|
||||||
@@ -105,7 +111,8 @@ QmlProfilerViewManager::~QmlProfilerViewManager()
|
|||||||
|
|
||||||
void QmlProfilerViewManager::clear()
|
void QmlProfilerViewManager::clear()
|
||||||
{
|
{
|
||||||
m_traceView->clear();
|
if (m_traceView)
|
||||||
|
m_traceView->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -58,8 +58,11 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void typeSelected(int typeId);
|
void typeSelected(int typeId);
|
||||||
void gotoSourceLocation(QString,int,int);
|
void gotoSourceLocation(QString,int,int);
|
||||||
|
void viewsCreated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void createViews();
|
||||||
|
|
||||||
QmlProfilerTraceView *m_traceView = nullptr;
|
QmlProfilerTraceView *m_traceView = nullptr;
|
||||||
QmlProfilerStatisticsView *m_statisticsView = nullptr;
|
QmlProfilerStatisticsView *m_statisticsView = nullptr;
|
||||||
FlameGraphView *m_flameGraphView = nullptr;
|
FlameGraphView *m_flameGraphView = nullptr;
|
||||||
|
Reference in New Issue
Block a user