2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2011-03-04 12:15:19 +01:00
|
|
|
|
|
|
|
|
#include "memcheckerrorview.h"
|
|
|
|
|
|
|
|
|
|
#include "suppressiondialog.h"
|
2011-05-23 13:50:28 +02:00
|
|
|
#include "valgrindsettings.h"
|
2022-07-08 16:08:27 +02:00
|
|
|
#include "valgrindtr.h"
|
2011-03-04 12:15:19 +01:00
|
|
|
|
2011-07-13 14:58:54 +02:00
|
|
|
#include "xmlprotocol/error.h"
|
|
|
|
|
#include "xmlprotocol/errorlistmodel.h"
|
|
|
|
|
#include "xmlprotocol/suppression.h"
|
2011-03-04 12:15:19 +01:00
|
|
|
|
2013-05-30 17:26:51 +02:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2011-03-04 12:15:19 +01:00
|
|
|
#include <projectexplorer/project.h>
|
2013-05-30 17:26:51 +02:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2013-09-05 11:46:07 +02:00
|
|
|
#include <projectexplorer/session.h>
|
2022-07-08 16:08:27 +02:00
|
|
|
|
2011-03-04 12:15:19 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2016-04-10 20:32:28 +02:00
|
|
|
#include <utils/icon.h>
|
|
|
|
|
#include <utils/theme/theme.h>
|
2011-03-04 12:15:19 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAction>
|
2011-03-04 12:15:19 +01:00
|
|
|
|
2021-09-30 17:12:10 +02:00
|
|
|
using namespace Utils;
|
2011-03-04 12:15:19 +01:00
|
|
|
using namespace Valgrind::XmlProtocol;
|
|
|
|
|
|
2011-05-23 13:50:28 +02:00
|
|
|
namespace Valgrind {
|
2011-05-18 17:05:49 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2011-03-04 12:15:19 +01:00
|
|
|
MemcheckErrorView::MemcheckErrorView(QWidget *parent)
|
2018-12-10 08:11:18 +01:00
|
|
|
: Debugger::DetailedErrorView(parent)
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
2011-03-04 16:00:04 +01:00
|
|
|
m_suppressAction = new QAction(this);
|
2022-07-08 16:08:27 +02:00
|
|
|
m_suppressAction->setText(Tr::tr("Suppress Error"));
|
2021-09-30 17:12:10 +02:00
|
|
|
const QIcon icon = Icon({
|
|
|
|
|
{":/utils/images/eye_open.png", Theme::TextColorNormal},
|
|
|
|
|
{":/valgrind/images/suppressoverlay.png", Theme::IconsErrorColor}},
|
|
|
|
|
Icon::Tint | Icon::PunchEdges).icon();
|
2016-04-10 20:32:28 +02:00
|
|
|
m_suppressAction->setIcon(icon);
|
2020-03-09 10:30:41 +01:00
|
|
|
m_suppressAction->setShortcuts({QKeySequence::Delete, QKeySequence::Backspace});
|
2011-03-04 16:00:04 +01:00
|
|
|
m_suppressAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
2014-10-09 17:04:22 +02:00
|
|
|
connect(m_suppressAction, &QAction::triggered, this, &MemcheckErrorView::suppressError);
|
2011-03-04 16:00:04 +01:00
|
|
|
addAction(m_suppressAction);
|
2011-03-04 12:15:19 +01:00
|
|
|
}
|
|
|
|
|
|
2018-12-10 08:11:18 +01:00
|
|
|
MemcheckErrorView::~MemcheckErrorView() = default;
|
2011-03-04 12:15:19 +01:00
|
|
|
|
2021-09-30 17:12:10 +02:00
|
|
|
void MemcheckErrorView::setDefaultSuppressionFile(const FilePath &suppFile)
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
|
|
|
|
m_defaultSuppFile = suppFile;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-30 17:12:10 +02:00
|
|
|
FilePath MemcheckErrorView::defaultSuppressionFile() const
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
|
|
|
|
return m_defaultSuppFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// slot, can (for now) be invoked either when the settings were modified *or* when the active
|
|
|
|
|
// settings object has changed.
|
2013-08-08 17:37:37 +02:00
|
|
|
void MemcheckErrorView::settingsChanged(ValgrindBaseSettings *settings)
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(settings, return);
|
|
|
|
|
m_settings = settings;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-11 16:12:58 +01:00
|
|
|
void MemcheckErrorView::suppressError()
|
|
|
|
|
{
|
|
|
|
|
SuppressionDialog::maybeShow(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QAction *> MemcheckErrorView::customActions() const
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
2015-02-11 16:12:58 +01:00
|
|
|
QList<QAction *> actions;
|
2011-03-04 12:15:19 +01:00
|
|
|
const QModelIndexList indizes = selectionModel()->selectedRows();
|
2015-02-11 16:12:58 +01:00
|
|
|
QTC_ASSERT(!indizes.isEmpty(), return actions);
|
2011-03-04 16:00:04 +01:00
|
|
|
|
2015-02-11 16:12:58 +01:00
|
|
|
bool hasErrors = false;
|
2022-05-17 11:53:31 +02:00
|
|
|
for (const QModelIndex &index : indizes) {
|
2011-03-04 12:15:19 +01:00
|
|
|
Error error = model()->data(index, ErrorListModel::ErrorRole).value<Error>();
|
2015-02-11 16:12:58 +01:00
|
|
|
if (!error.suppression().isNull()) {
|
|
|
|
|
hasErrors = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-03-04 12:15:19 +01:00
|
|
|
}
|
2015-02-11 16:12:58 +01:00
|
|
|
m_suppressAction->setEnabled(hasErrors);
|
|
|
|
|
actions << m_suppressAction;
|
|
|
|
|
return actions;
|
2011-03-04 12:15:19 +01:00
|
|
|
}
|
2011-05-18 17:05:49 +02:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
2011-05-23 13:50:28 +02:00
|
|
|
} // namespace Valgrind
|