2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-03-04 12:15:19 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
2011-03-04 12:15:19 +01:00
|
|
|
** Author: Andreas Hartmetz, KDAB (andreas.hartmetz@kdab.com)
|
2016-01-15 14:57:40 +01:00
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-03-04 12:15:19 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-03-04 12:15:19 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2011-03-04 12:15:19 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2011-03-04 12:15:19 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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"
|
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/frame.h"
|
|
|
|
|
#include "xmlprotocol/stack.h"
|
|
|
|
|
#include "xmlprotocol/modelhelpers.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>
|
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);
|
|
|
|
|
m_suppressAction->setText(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
|