File indexing completed on 2024-04-28 12:23:24
0001 /* This file is part of KDevelop 0002 * Copyright 2011 Sebastien Rannou <mxs@sbrk.org> 0003 * Copyright 2008 Hamish Rodda <rodda@kde.org> 0004 * Copyright 2017 Anton Anikin <anton@anikin.xyz> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 0011 This program is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 General Public License for more details. 0015 0016 You should have received a copy of the GNU General Public License 0017 along with this program; see the file COPYING. If not, write to 0018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #include "massif_view.h" 0023 #include "ui_massif_view.h" 0024 0025 #include "debug.h" 0026 #include "massif_config.h" 0027 #include "massif_model.h" 0028 #include "massif_snapshot.h" 0029 #include "utils.h" 0030 0031 #include <QStringListModel> 0032 #include <QProcess> 0033 #include <QTemporaryFile> 0034 0035 namespace Valgrind 0036 { 0037 0038 MassifView::MassifView(KConfigGroup configGroup, QTemporaryFile* outputFile, MassifSnapshotsModel* model, QWidget* parent) 0039 : QWidget(parent) 0040 , ui(new Ui::MassifView) 0041 , m_visualizerProcess(new QProcess) 0042 { 0043 Q_ASSERT(model); 0044 model->setParent(this); 0045 0046 Q_ASSERT(outputFile); 0047 outputFile->setParent(this); 0048 0049 ui->setupUi(this); 0050 0051 auto treesModel = new QStringListModel(this); 0052 ui->treesView->setModel(treesModel); 0053 0054 ui->snapshotsView->setModel(model); 0055 ui->snapshotsView->header()->resizeSections(QHeaderView::ResizeToContents); 0056 0057 connect(ui->snapshotsView->selectionModel(), &QItemSelectionModel::currentChanged, this, 0058 [treesModel](const QModelIndex& current, const QModelIndex&) { 0059 auto snapshot = static_cast<MassifSnapshot*>(current.internalPointer()); 0060 treesModel->setStringList(snapshot->heapTree); 0061 }); 0062 0063 auto startVisualizer = [this, outputFile]() { 0064 m_visualizerProcess->start(MassifConfig::visualizerExecutablePath(), 0065 { outputFile->fileName() }); 0066 }; 0067 0068 MassifConfig config; 0069 config.setConfigGroup(configGroup); 0070 config.load(); 0071 0072 setupVisualizerProcess(m_visualizerProcess.data(), 0073 ui->launchVisualizerButton, 0074 startVisualizer, config.launchVisualizer()); 0075 } 0076 0077 MassifView::~MassifView() 0078 { 0079 m_visualizerProcess->disconnect(); // FIXME is this really needed ? 0080 } 0081 0082 }