Callgrind: Support opening last results in KCachegrind

Change-Id: Idb3b08ca6a1837f2456b73bcaf19aced5b83179f
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2018-11-07 23:55:59 +02:00
committed by Orgad Shaneh
parent 2c212d48a5
commit 7c56b2c310
12 changed files with 168 additions and 17 deletions

View File

@@ -186,6 +186,8 @@ public:
QPointer<CostView> m_calleesView;
QPointer<Visualization> m_visualization;
QString m_lastFileName;
// Navigation
QAction *m_goBack = nullptr;
QAction *m_goNext = nullptr;
@@ -207,6 +209,7 @@ public:
QAction *m_startAction = nullptr;
QAction *m_stopAction = nullptr;
QAction *m_loadExternalLogFile = nullptr;
QAction *m_startKCachegrind = nullptr;
QAction *m_dumpAction = nullptr;
QAction *m_resetAction = nullptr;
QAction *m_pauseAction = nullptr;
@@ -355,6 +358,8 @@ CallgrindTool::CallgrindTool()
updateCostFormat();
ValgrindGlobalSettings *settings = ValgrindPlugin::globalSettings();
//
// Control Widget
//
@@ -365,6 +370,16 @@ CallgrindTool::CallgrindTool()
action->setToolTip(tr("Load External Log File"));
connect(action, &QAction::triggered, this, &CallgrindTool::loadExternalLogFile);
action = m_startKCachegrind = new QAction(this);
action->setEnabled(false);
const Utils::Icon kCachegrindIcon({{":/valgrind/images/kcachegrind.png",
Theme::IconsBaseColor}});
action->setIcon(kCachegrindIcon.icon());
action->setToolTip(tr("Open results in KCachegrind."));
connect(action, &QAction::triggered, this, [this, settings] {
QProcess::startDetached(settings->kcachegrindExecutable(), { m_lastFileName });
});
// dump action
m_dumpAction = action = new QAction(this);
action->setDisabled(true);
@@ -423,6 +438,7 @@ CallgrindTool::CallgrindTool()
m_perspective.addToolBarAction(m_startAction);
m_perspective.addToolBarAction(m_stopAction);
m_perspective.addToolBarAction(m_loadExternalLogFile);
m_perspective.addToolBarAction(m_startKCachegrind);
m_perspective.addToolBarAction(m_dumpAction);
m_perspective.addToolBarAction(m_resetAction);
m_perspective.addToolBarAction(m_pauseAction);
@@ -466,8 +482,6 @@ CallgrindTool::CallgrindTool()
m_perspective.addToolBarWidget(button);
}
ValgrindGlobalSettings *settings = ValgrindPlugin::globalSettings();
// Cycle detection
//action = new QAction("Cycle Detection", this); ///FIXME: icon
action = m_cycleDetection = new QAction("O", this); ///FIXME: icon
@@ -713,6 +727,7 @@ void CallgrindTool::setParseData(ParseData *data)
delete data;
data = nullptr;
}
m_lastFileName = data ? data->fileName() : QString();
m_dataModel.setParseData(data);
m_calleesModel.setParseData(data);
m_callersModel.setParseData(data);
@@ -919,14 +934,21 @@ void CallgrindTool::takeParserData(ParseData *data)
{
showParserResults(data);
if (!data)
if (!data) {
m_lastFileName.clear();
m_startKCachegrind->setEnabled(false);
return;
}
// clear first
clearTextMarks();
doClear(true);
setParseData(data);
const QString kcachegrindExecutable = ValgrindPlugin::globalSettings()->kcachegrindExecutable();
const bool kcachegrindExists = !Utils::Environment::systemEnvironment().searchInPath(
kcachegrindExecutable).isEmpty();
m_startKCachegrind->setEnabled(kcachegrindExists && !m_lastFileName.isEmpty());
createTextMarks();
}