forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.7'
Change-Id: Ib288796892faf5345d2a150a5ce0dadf91552924
This commit is contained in:
@@ -28,26 +28,6 @@
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
QDataStream &operator>>(QDataStream &stream, QmlEventType &type)
|
||||
{
|
||||
quint8 message;
|
||||
quint8 rangeType;
|
||||
QString displayName;
|
||||
stream >> displayName >> type.m_data >> type.m_location >> message >> rangeType
|
||||
>> type.m_detailType;
|
||||
type.setDisplayName(displayName);
|
||||
type.m_message = static_cast<Message>(message);
|
||||
type.m_rangeType = static_cast<RangeType>(rangeType);
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &stream, const QmlEventType &type)
|
||||
{
|
||||
return stream << type.displayName() << type.m_data << type.m_location
|
||||
<< static_cast<quint8>(type.m_message) << static_cast<quint8>(type.m_rangeType)
|
||||
<< type.m_detailType;
|
||||
}
|
||||
|
||||
static ProfileFeature qmlFeatureFromType(Message message, RangeType rangeType, int detailType)
|
||||
{
|
||||
switch (message) {
|
||||
@@ -75,6 +55,27 @@ static ProfileFeature qmlFeatureFromType(Message message, RangeType rangeType, i
|
||||
}
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &stream, QmlEventType &type)
|
||||
{
|
||||
quint8 message;
|
||||
quint8 rangeType;
|
||||
QString displayName;
|
||||
stream >> displayName >> type.m_data >> type.m_location >> message >> rangeType
|
||||
>> type.m_detailType;
|
||||
type.setDisplayName(displayName);
|
||||
type.m_message = static_cast<Message>(message);
|
||||
type.m_rangeType = static_cast<RangeType>(rangeType);
|
||||
type.setFeature(qmlFeatureFromType(type.m_message, type.m_rangeType, type.m_detailType));
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &stream, const QmlEventType &type)
|
||||
{
|
||||
return stream << type.displayName() << type.m_data << type.m_location
|
||||
<< static_cast<quint8>(type.m_message) << static_cast<quint8>(type.m_rangeType)
|
||||
<< type.m_detailType;
|
||||
}
|
||||
|
||||
QmlEventType::QmlEventType(Message message, RangeType rangeType, int detailType,
|
||||
const QmlEventLocation &location, const QString &data,
|
||||
const QString displayName) :
|
||||
|
||||
@@ -15,6 +15,7 @@ SOURCES += \
|
||||
qmleventlocation.cpp \
|
||||
qmleventtype.cpp \
|
||||
qmlnote.cpp \
|
||||
qmlprofileractions.cpp \
|
||||
qmlprofileranimationsmodel.cpp \
|
||||
qmlprofilerattachdialog.cpp \
|
||||
qmlprofilerbindingloopsrenderpass.cpp \
|
||||
@@ -55,6 +56,7 @@ HEADERS += \
|
||||
qmleventtype.h \
|
||||
qmlnote.h \
|
||||
qmlprofiler_global.h \
|
||||
qmlprofileractions.h \
|
||||
qmlprofileranimationsmodel.h \
|
||||
qmlprofilerattachdialog.h \
|
||||
qmlprofilerbindingloopsrenderpass.h \
|
||||
|
||||
@@ -31,6 +31,7 @@ QtcPlugin {
|
||||
"qmleventtype.cpp", "qmleventtype.h",
|
||||
"qmlnote.cpp", "qmlnote.h",
|
||||
"qmlprofiler_global.h",
|
||||
"qmlprofileractions.h", "qmlprofileractions.cpp",
|
||||
"qmlprofileranimationsmodel.h", "qmlprofileranimationsmodel.cpp",
|
||||
"qmlprofilerattachdialog.cpp", "qmlprofilerattachdialog.h",
|
||||
"qmlprofilerbindingloopsrenderpass.cpp","qmlprofilerbindingloopsrenderpass.h",
|
||||
|
||||
113
src/plugins/qmlprofiler/qmlprofileractions.cpp
Normal file
113
src/plugins/qmlprofiler/qmlprofileractions.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlprofileractions.h"
|
||||
#include "qmlprofilerconstants.h"
|
||||
#include "qmlprofilertool.h"
|
||||
#include "qmlprofilerstatemanager.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
|
||||
#include <debugger/analyzer/analyzerconstants.h>
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
using namespace Core;
|
||||
using namespace Debugger::Constants;
|
||||
|
||||
QmlProfilerActions::QmlProfilerActions(QObject *parent) : QObject(parent)
|
||||
{}
|
||||
|
||||
void QmlProfilerActions::attachToTool(QmlProfilerTool *tool)
|
||||
{
|
||||
const QString description = tr("The QML Profiler can be used to find performance "
|
||||
"bottlenecks in applications using QML.");
|
||||
|
||||
m_runAction = std::make_unique<QAction>(tr("QML Profiler"));
|
||||
m_runAction->setToolTip(description);
|
||||
QObject::connect(m_runAction.get(), &QAction::triggered,
|
||||
tool, &QmlProfilerTool::profileStartupProject);
|
||||
|
||||
QAction *toolStartAction = tool->startAction();
|
||||
QObject::connect(toolStartAction, &QAction::changed, this, [this, toolStartAction] {
|
||||
m_runAction->setEnabled(toolStartAction->isEnabled());
|
||||
});
|
||||
|
||||
m_attachAction = std::make_unique<QAction>(tr("QML Profiler (Attach to Waiting Application)"));
|
||||
m_attachAction->setToolTip(description);
|
||||
QObject::connect(m_attachAction.get(), &QAction::triggered,
|
||||
tool, &QmlProfilerTool::attachToWaitingApplication);
|
||||
|
||||
m_loadQmlTrace = std::make_unique<QAction>(tr("Load QML Trace"));
|
||||
connect(m_loadQmlTrace.get(), &QAction::triggered,
|
||||
tool, &QmlProfilerTool::showLoadDialog, Qt::QueuedConnection);
|
||||
|
||||
m_saveQmlTrace = std::make_unique<QAction>(tr("Save QML Trace"));
|
||||
connect(m_saveQmlTrace.get(), &QAction::triggered,
|
||||
tool, &QmlProfilerTool::showSaveDialog, Qt::QueuedConnection);
|
||||
|
||||
QmlProfilerStateManager *stateManager = tool->stateManager();
|
||||
connect(stateManager, &QmlProfilerStateManager::serverRecordingChanged,
|
||||
this, [this, stateManager](bool recording) {
|
||||
m_loadQmlTrace->setEnabled(!recording);
|
||||
});
|
||||
m_loadQmlTrace->setEnabled(!stateManager->serverRecording());
|
||||
|
||||
QmlProfilerModelManager *modelManager = tool->modelManager();
|
||||
connect(modelManager, &QmlProfilerModelManager::traceChanged,
|
||||
this, [this, modelManager] {
|
||||
m_saveQmlTrace->setEnabled(!modelManager->isEmpty());
|
||||
});
|
||||
m_saveQmlTrace->setEnabled(!modelManager->isEmpty());
|
||||
}
|
||||
|
||||
void QmlProfilerActions::registerActions()
|
||||
{
|
||||
m_options.reset(ActionManager::createMenu("Analyzer.Menu.QMLOptions"));
|
||||
m_options->menu()->setTitle(tr("QML Profiler Options"));
|
||||
m_options->menu()->setEnabled(true);
|
||||
ActionContainer *menu = ActionManager::actionContainer(M_DEBUG_ANALYZER);
|
||||
|
||||
menu->addAction(ActionManager::registerAction(m_runAction.get(),
|
||||
"QmlProfiler.Internal"),
|
||||
Debugger::Constants::G_ANALYZER_TOOLS);
|
||||
menu->addAction(ActionManager::registerAction(m_attachAction.get(),
|
||||
"QmlProfiler.AttachToWaitingApplication"),
|
||||
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||
|
||||
menu->addMenu(m_options.get(), G_ANALYZER_OPTIONS);
|
||||
m_options->addAction(ActionManager::registerAction(m_loadQmlTrace.get(),
|
||||
Constants::QmlProfilerLoadActionId));
|
||||
m_options->addAction(ActionManager::registerAction(m_saveQmlTrace.get(),
|
||||
Constants::QmlProfilerSaveActionId));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
57
src/plugins/qmlprofiler/qmlprofileractions.h
Normal file
57
src/plugins/qmlprofiler/qmlprofileractions.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QAction>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
class QmlProfilerTool;
|
||||
class QmlProfilerActions : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlProfilerActions(QObject *parent = nullptr);
|
||||
|
||||
void attachToTool(QmlProfilerTool *tool);
|
||||
void registerActions();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Core::ActionContainer> m_options;
|
||||
std::unique_ptr<QAction> m_loadQmlTrace;
|
||||
std::unique_ptr<QAction> m_saveQmlTrace;
|
||||
std::unique_ptr<QAction> m_runAction;
|
||||
std::unique_ptr<QAction> m_attachAction;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
@@ -123,7 +123,7 @@ QmlProfilerModelManager::QmlProfilerModelManager(QObject *parent) :
|
||||
|
||||
d->detailsRewriter = new Internal::QmlProfilerDetailsRewriter(this);
|
||||
connect(d->detailsRewriter, &Internal::QmlProfilerDetailsRewriter::rewriteDetailsString,
|
||||
this, &QmlProfilerModelManager::typeDetailsChanged);
|
||||
this, &QmlProfilerModelManager::setTypeDetails);
|
||||
connect(d->detailsRewriter, &Internal::QmlProfilerDetailsRewriter::eventDetailsChanged,
|
||||
this, &QmlProfilerModelManager::typeDetailsFinished);
|
||||
|
||||
@@ -202,6 +202,24 @@ void QmlProfilerModelManager::replayQmlEvents(QmlEventLoader loader,
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::initialize()
|
||||
{
|
||||
d->textMarkModel->hideTextMarks();
|
||||
TimelineTraceManager::initialize();
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::clearEventStorage()
|
||||
{
|
||||
TimelineTraceManager::clearEventStorage();
|
||||
emit traceChanged();
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::clearTypeStorage()
|
||||
{
|
||||
d->textMarkModel->clear();
|
||||
TimelineTraceManager::clearTypeStorage();
|
||||
}
|
||||
|
||||
static QString getDisplayName(const QmlEventType &event)
|
||||
{
|
||||
if (event.location().filename().isEmpty()) {
|
||||
@@ -255,6 +273,8 @@ void QmlProfilerModelManager::finalize()
|
||||
// which happens on stateChanged(Done).
|
||||
|
||||
TimelineTraceManager::finalize();
|
||||
d->textMarkModel->showTextMarks();
|
||||
emit traceChanged();
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::populateFileFinder(const ProjectExplorer::Target *target)
|
||||
@@ -267,12 +287,13 @@ QString QmlProfilerModelManager::findLocalFile(const QString &remoteFile)
|
||||
return d->detailsRewriter->getLocalFile(remoteFile);
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::detailsChanged(int typeId, const QString &newString)
|
||||
void QmlProfilerModelManager::setTypeDetails(int typeId, const QString &details)
|
||||
{
|
||||
QTC_ASSERT(typeId < numEventTypes(), return);
|
||||
QmlEventType type = eventType(typeId);
|
||||
type.setData(newString);
|
||||
setEventType(typeId, std::move(type));
|
||||
type.setData(details);
|
||||
// Don't rewrite the details again, but directly push the type into the type storage.
|
||||
Timeline::TimelineTraceManager::setEventType(typeId, std::move(type));
|
||||
emit typeDetailsChanged(typeId);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
void replayQmlEvents(QmlEventLoader loader, Initializer initializer, Finalizer finalizer,
|
||||
ErrorHandler errorHandler, QFutureInterface<void> &future) const;
|
||||
|
||||
void initialize() override;
|
||||
void finalize() override;
|
||||
|
||||
void populateFileFinder(const ProjectExplorer::Target *target = nullptr);
|
||||
@@ -83,13 +84,17 @@ public:
|
||||
QmlEventFilter rangeFilter(qint64 start, qint64 end) const;
|
||||
|
||||
signals:
|
||||
void traceChanged();
|
||||
void typeDetailsChanged(int typeId);
|
||||
void typeDetailsFinished();
|
||||
|
||||
private:
|
||||
void detailsChanged(int typeId, const QString &newString);
|
||||
void setTypeDetails(int typeId, const QString &details);
|
||||
void restrictByFilter(QmlEventFilter filter);
|
||||
|
||||
void clearEventStorage() final;
|
||||
void clearTypeStorage() final;
|
||||
|
||||
Timeline::TimelineTraceFile *createTraceFile() override;
|
||||
void replayEvents(TraceEventLoader loader, Initializer initializer, Finalizer finalizer,
|
||||
ErrorHandler errorHandler, QFutureInterface<void> &future) const override;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "qmlprofilersettings.h"
|
||||
#include "qmlprofilertool.h"
|
||||
#include "qmlprofilertimelinemodel.h"
|
||||
#include "qmlprofileractions.h"
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
@@ -84,6 +85,7 @@ class QmlProfilerPluginPrivate
|
||||
public:
|
||||
QmlProfilerTool m_profilerTool;
|
||||
QmlProfilerOptionsPage m_profilerOptionsPage;
|
||||
QmlProfilerActions m_actions;
|
||||
};
|
||||
|
||||
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
@@ -99,6 +101,8 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
void QmlProfilerPlugin::extensionsInitialized()
|
||||
{
|
||||
d = new QmlProfilerPluginPrivate;
|
||||
d->m_actions.attachToTool(&d->m_profilerTool);
|
||||
d->m_actions.registerActions();
|
||||
|
||||
RunConfiguration::registerAspect<QmlProfilerRunConfigurationAspect>();
|
||||
|
||||
|
||||
@@ -274,8 +274,14 @@ void QmlProfilerStatisticsMainView::jumpToItem(int typeIndex)
|
||||
{
|
||||
displayTypeIndex(typeIndex);
|
||||
|
||||
QSortFilterProxyModel *sortModel = qobject_cast<QSortFilterProxyModel *>(model());
|
||||
QTC_ASSERT(sortModel, return);
|
||||
|
||||
QAbstractItemModel *sourceModel = sortModel->sourceModel();
|
||||
QTC_ASSERT(sourceModel, return);
|
||||
|
||||
// show in editor
|
||||
getSourceLocation(model()->index(typeIndex, MainLocation),
|
||||
getSourceLocation(sourceModel->index(typeIndex, MainLocation),
|
||||
[this](const QString &fileName, int line, int column) {
|
||||
emit gotoSourceLocation(fileName, line, column);
|
||||
});
|
||||
|
||||
@@ -119,6 +119,18 @@ void QmlProfilerTextMarkModel::createMarks(QmlProfilerViewManager *viewManager,
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerTextMarkModel::showTextMarks()
|
||||
{
|
||||
for (QmlProfilerTextMark *mark : qAsConst(m_marks))
|
||||
mark->setVisible(true);
|
||||
}
|
||||
|
||||
void QmlProfilerTextMarkModel::hideTextMarks()
|
||||
{
|
||||
for (QmlProfilerTextMark *mark : qAsConst(m_marks))
|
||||
mark->setVisible(false);
|
||||
}
|
||||
|
||||
bool QmlProfilerTextMark::addToolTipContent(QLayout *target) const
|
||||
{
|
||||
QGridLayout *layout = new QGridLayout;
|
||||
|
||||
@@ -59,6 +59,9 @@ public:
|
||||
void addTextMarkId(int typeId, const QmlEventLocation &location);
|
||||
void createMarks(QmlProfilerViewManager *viewManager, const QString &fileName);
|
||||
|
||||
void showTextMarks();
|
||||
void hideTextMarks();
|
||||
|
||||
private:
|
||||
struct TextMarkId {
|
||||
int typeId;
|
||||
|
||||
@@ -105,6 +105,7 @@ QVariantMap QmlProfilerTimelineModel::locationFromTypeId(int index) const
|
||||
|
||||
void QmlProfilerTimelineModel::initialize()
|
||||
{
|
||||
setHidden(!(modelManager()->visibleFeatures() & (1ULL << m_mainFeature)));
|
||||
}
|
||||
|
||||
void QmlProfilerTimelineModel::finalize()
|
||||
|
||||
@@ -57,6 +57,8 @@
|
||||
#include <projectexplorer/taskhub.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/find/findplugin.h>
|
||||
@@ -66,9 +68,6 @@
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <coreplugin/imode.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
@@ -117,10 +116,6 @@ public:
|
||||
QToolButton *m_displayFeaturesButton = nullptr;
|
||||
QMenu *m_displayFeaturesMenu = nullptr;
|
||||
|
||||
// save and load actions
|
||||
QAction *m_saveQmlTrace = nullptr;
|
||||
QAction *m_loadQmlTrace = nullptr;
|
||||
|
||||
// elapsed time display
|
||||
QLabel *m_timeLabel = nullptr;
|
||||
QTimer m_recordingTimer;
|
||||
@@ -163,24 +158,6 @@ QmlProfilerTool::QmlProfilerTool()
|
||||
this, &QmlProfilerTool::onLoadSaveFinished);
|
||||
|
||||
d->m_profilerConnections->setModelManager(d->m_profilerModelManager);
|
||||
Command *command = nullptr;
|
||||
|
||||
ActionContainer *menu = ActionManager::actionContainer(M_DEBUG_ANALYZER);
|
||||
ActionContainer *options = ActionManager::createMenu("Analyzer.Menu.QMLOptions");
|
||||
options->menu()->setTitle(tr("QML Profiler Options"));
|
||||
menu->addMenu(options, G_ANALYZER_OPTIONS);
|
||||
options->menu()->setEnabled(true);
|
||||
|
||||
QAction *act = d->m_loadQmlTrace = new QAction(tr("Load QML Trace"), options);
|
||||
command = ActionManager::registerAction(act, Constants::QmlProfilerLoadActionId);
|
||||
connect(act, &QAction::triggered, this, &QmlProfilerTool::showLoadDialog, Qt::QueuedConnection);
|
||||
options->addAction(command);
|
||||
|
||||
act = d->m_saveQmlTrace = new QAction(tr("Save QML Trace"), options);
|
||||
d->m_saveQmlTrace->setEnabled(false);
|
||||
command = ActionManager::registerAction(act, Constants::QmlProfilerSaveActionId);
|
||||
connect(act, &QAction::triggered, this, &QmlProfilerTool::showSaveDialog, Qt::QueuedConnection);
|
||||
options->addAction(command);
|
||||
|
||||
d->m_recordingTimer.setInterval(100);
|
||||
connect(&d->m_recordingTimer, &QTimer::timeout, this, &QmlProfilerTool::updateTimeDisplay);
|
||||
@@ -246,32 +223,10 @@ QmlProfilerTool::QmlProfilerTool()
|
||||
// is available, then we can populate the file finder
|
||||
d->m_profilerModelManager->populateFileFinder();
|
||||
|
||||
QString description = tr("The QML Profiler can be used to find performance "
|
||||
"bottlenecks in applications using QML.");
|
||||
|
||||
d->m_startAction = Debugger::createStartAction();
|
||||
d->m_stopAction = Debugger::createStopAction();
|
||||
|
||||
act = new QAction(tr("QML Profiler"), this);
|
||||
act->setToolTip(description);
|
||||
menu->addAction(ActionManager::registerAction(act, "QmlProfiler.Internal"),
|
||||
Debugger::Constants::G_ANALYZER_TOOLS);
|
||||
QObject::connect(act, &QAction::triggered, this, [this] {
|
||||
if (!prepareTool())
|
||||
return;
|
||||
Debugger::selectPerspective(Constants::QmlProfilerPerspectiveId);
|
||||
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
});
|
||||
QObject::connect(d->m_startAction, &QAction::triggered, act, &QAction::triggered);
|
||||
QObject::connect(d->m_startAction, &QAction::changed, act, [act, this] {
|
||||
act->setEnabled(d->m_startAction->isEnabled());
|
||||
});
|
||||
|
||||
act = new QAction(tr("QML Profiler (Attach to Waiting Application)"), this);
|
||||
act->setToolTip(description);
|
||||
menu->addAction(ActionManager::registerAction(act, "QmlProfiler.AttachToWaitingApplication"),
|
||||
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||
QObject::connect(act, &QAction::triggered, this, &QmlProfilerTool::attachToWaitingApplication);
|
||||
QObject::connect(d->m_startAction, &QAction::triggered, this, &QmlProfilerTool::profileStartupProject);
|
||||
|
||||
Utils::ToolbarDescription toolbar;
|
||||
toolbar.addAction(d->m_startAction);
|
||||
@@ -361,6 +316,13 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker)
|
||||
d->m_toolBusy = false;
|
||||
updateRunActions();
|
||||
disconnect(d->m_stopAction, &QAction::triggered, runControl, &RunControl::initiateStop);
|
||||
|
||||
// If we're still trying to connect, stop now.
|
||||
if (d->m_profilerConnections->isConnecting()) {
|
||||
showNonmodalWarning(tr("The application finished before a connection could be "
|
||||
"established. No data was loaded."));
|
||||
d->m_profilerConnections->disconnectFromServer();
|
||||
}
|
||||
};
|
||||
|
||||
connect(runControl, &RunControl::stopped, this, handleStop);
|
||||
@@ -516,18 +478,13 @@ void QmlProfilerTool::setButtonsEnabled(bool enable)
|
||||
d->m_recordFeaturesMenu->setEnabled(enable);
|
||||
}
|
||||
|
||||
void QmlProfilerTool::createTextMarks()
|
||||
void QmlProfilerTool::createInitialTextMarks()
|
||||
{
|
||||
QmlProfilerTextMarkModel *model = d->m_profilerModelManager->textMarkModel();
|
||||
foreach (IDocument *document, DocumentModel::openedDocuments())
|
||||
model->createMarks(d->m_viewContainer, document->filePath().toString());
|
||||
}
|
||||
|
||||
void QmlProfilerTool::clearTextMarks()
|
||||
{
|
||||
d->m_profilerModelManager->textMarkModel()->clear();
|
||||
}
|
||||
|
||||
bool QmlProfilerTool::prepareTool()
|
||||
{
|
||||
if (d->m_profilerState->clientRecording()) {
|
||||
@@ -618,16 +575,6 @@ void QmlProfilerTool::showErrorDialog(const QString &error)
|
||||
errorDialog->show();
|
||||
}
|
||||
|
||||
void QmlProfilerTool::showLoadOption()
|
||||
{
|
||||
d->m_loadQmlTrace->setEnabled(!d->m_profilerState->serverRecording());
|
||||
}
|
||||
|
||||
void QmlProfilerTool::showSaveOption()
|
||||
{
|
||||
d->m_saveQmlTrace->setEnabled(!d->m_profilerModelManager->isEmpty());
|
||||
}
|
||||
|
||||
void saveLastTraceFile(const QString &filename)
|
||||
{
|
||||
QmlProfilerSettings *settings = QmlProfilerPlugin::globalSettings();
|
||||
@@ -681,6 +628,24 @@ void QmlProfilerTool::showLoadDialog()
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerTool::profileStartupProject()
|
||||
{
|
||||
if (!prepareTool())
|
||||
return;
|
||||
Debugger::selectPerspective(Constants::QmlProfilerPerspectiveId);
|
||||
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
}
|
||||
|
||||
QAction *QmlProfilerTool::startAction() const
|
||||
{
|
||||
return d->m_startAction;
|
||||
}
|
||||
|
||||
QAction *QmlProfilerTool::stopAction() const
|
||||
{
|
||||
return d->m_stopAction;
|
||||
}
|
||||
|
||||
void QmlProfilerTool::onLoadSaveFinished()
|
||||
{
|
||||
disconnect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged,
|
||||
@@ -704,24 +669,12 @@ bool QmlProfilerTool::checkForUnsavedNotes()
|
||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes;
|
||||
}
|
||||
|
||||
void QmlProfilerTool::restoreFeatureVisibility()
|
||||
{
|
||||
// Restore the shown/hidden state of features to what the user selected. When clearing data the
|
||||
// the model manager sets its features to 0, and models get automatically shown, for the mockup.
|
||||
quint64 features = 0;
|
||||
foreach (const QAction *action, d->m_displayFeaturesMenu->actions()) {
|
||||
if (action->isChecked())
|
||||
features |= (1ULL << action->data().toUInt());
|
||||
}
|
||||
d->m_profilerModelManager->setVisibleFeatures(features);
|
||||
}
|
||||
|
||||
void QmlProfilerTool::clientsDisconnected()
|
||||
{
|
||||
if (d->m_toolBusy) {
|
||||
if (d->m_profilerModelManager->aggregateTraces()) {
|
||||
d->m_profilerModelManager->finalize();
|
||||
} else {
|
||||
} else if (d->m_profilerState->serverRecording()) {
|
||||
// If the application stopped by itself, check if we have all the data
|
||||
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying ||
|
||||
d->m_profilerState->currentState() == QmlProfilerStateManager::Idle) {
|
||||
@@ -787,22 +740,19 @@ void QmlProfilerTool::setRecordedFeatures(quint64 features)
|
||||
|
||||
void QmlProfilerTool::initialize()
|
||||
{
|
||||
restoreFeatureVisibility();
|
||||
setButtonsEnabled(false); // Other buttons disabled
|
||||
}
|
||||
|
||||
void QmlProfilerTool::finalize()
|
||||
{
|
||||
showSaveOption();
|
||||
updateTimeDisplay();
|
||||
createTextMarks();
|
||||
createInitialTextMarks();
|
||||
setButtonsEnabled(true);
|
||||
d->m_recordButton->setEnabled(true);
|
||||
}
|
||||
|
||||
void QmlProfilerTool::clear()
|
||||
{
|
||||
clearTextMarks();
|
||||
clearDisplay();
|
||||
setButtonsEnabled(true);
|
||||
d->m_recordButton->setEnabled(true);
|
||||
@@ -878,7 +828,6 @@ void QmlProfilerTool::profilerStateChanged()
|
||||
|
||||
void QmlProfilerTool::serverRecordingChanged()
|
||||
{
|
||||
showLoadOption();
|
||||
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) {
|
||||
// clear the old data each time we start a new profiling session
|
||||
if (d->m_profilerState->serverRecording()) {
|
||||
|
||||
@@ -77,6 +77,14 @@ public:
|
||||
|
||||
void gotoSourceLocation(const QString &fileUrl, int lineNumber, int columnNumber);
|
||||
|
||||
void showSaveDialog();
|
||||
void showLoadDialog();
|
||||
|
||||
void profileStartupProject();
|
||||
|
||||
QAction *startAction() const;
|
||||
QAction *stopAction() const;
|
||||
|
||||
private:
|
||||
void clearEvents();
|
||||
void clearData();
|
||||
@@ -85,10 +93,6 @@ private:
|
||||
void updateTimeDisplay();
|
||||
void showTimeLineSearch();
|
||||
|
||||
void showSaveOption();
|
||||
void showLoadOption();
|
||||
void showSaveDialog();
|
||||
void showLoadDialog();
|
||||
void onLoadSaveFinished();
|
||||
|
||||
void toggleRequestedFeature(QAction *action);
|
||||
@@ -99,10 +103,8 @@ private:
|
||||
template<ProfileFeature feature>
|
||||
void updateFeatures(quint64 features);
|
||||
bool checkForUnsavedNotes();
|
||||
void restoreFeatureVisibility();
|
||||
void setButtonsEnabled(bool enable);
|
||||
void createTextMarks();
|
||||
void clearTextMarks();
|
||||
void createInitialTextMarks();
|
||||
|
||||
void initialize();
|
||||
void finalize();
|
||||
|
||||
@@ -191,6 +191,8 @@ void QmlProfilerTraceFile::loadQtd(QIODevice *device)
|
||||
|
||||
if (stream.hasError())
|
||||
fail(tr("Error while parsing trace data file: %1").arg(stream.errorString()));
|
||||
else
|
||||
finish();
|
||||
}
|
||||
|
||||
void QmlProfilerTraceFile::loadQzt(QIODevice *device)
|
||||
@@ -285,6 +287,8 @@ void QmlProfilerTraceFile::loadQzt(QIODevice *device)
|
||||
buffer.close();
|
||||
setDeviceProgress(device);
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
void QmlProfilerTraceFile::addEventsProgress(qint64 timestamp)
|
||||
|
||||
@@ -96,6 +96,9 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
||||
|
||||
connectRunner();
|
||||
|
||||
QTest::ignoreMessage(
|
||||
QtDebugMsg, "Invalid run control state transition from "
|
||||
"\"RunControlState::Starting\" to \"RunControlState::Stopped\"");
|
||||
runControl->initiateStart();
|
||||
|
||||
QTRY_COMPARE_WITH_TIMEOUT(startCount, 1, 30000);
|
||||
|
||||
@@ -136,6 +136,7 @@ void QmlEventTypeTest::testStreamOps()
|
||||
|
||||
rstream >> type2;
|
||||
|
||||
QCOMPARE(type.feature(), type2.feature());
|
||||
QCOMPARE(type.message(), type2.message());
|
||||
QCOMPARE(type.rangeType(), type2.rangeType());
|
||||
QCOMPARE(type.detailType(), type2.detailType());
|
||||
|
||||
Reference in New Issue
Block a user