Valgrind: Modernize

modernize-*

Change-Id: I6db60dce78cf2575e36caa597b1f095adba34fd9
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Alessandro Portale
2018-12-10 08:11:18 +01:00
parent 390a227df6
commit 00ec6dfb5d
53 changed files with 182 additions and 294 deletions

View File

@@ -39,10 +39,10 @@ namespace Callgrind {
class CallModel::Private class CallModel::Private
{ {
public: public:
const ParseData *m_data = 0; const ParseData *m_data = nullptr;
QVector<const FunctionCall *> m_calls; QVector<const FunctionCall *> m_calls;
int m_event = 0; int m_event = 0;
const Function *m_function = 0; const Function *m_function = nullptr;
}; };
CallModel::CallModel() CallModel::CallModel()
@@ -58,7 +58,7 @@ CallModel::~CallModel()
void CallModel::clear() void CallModel::clear()
{ {
beginResetModel(); beginResetModel();
d->m_function = 0; d->m_function = nullptr;
d->m_calls.clear(); d->m_calls.clear();
endResetModel(); endResetModel();
} }

View File

@@ -48,9 +48,7 @@ namespace Callgrind {
const char CALLGRIND_CONTROL_BINARY[] = "callgrind_control"; const char CALLGRIND_CONTROL_BINARY[] = "callgrind_control";
CallgrindController::CallgrindController() CallgrindController::CallgrindController() = default;
{
}
CallgrindController::~CallgrindController() CallgrindController::~CallgrindController()
{ {

View File

@@ -44,18 +44,16 @@ public:
QVector<quint64> m_positions; QVector<quint64> m_positions;
QVector<quint64> m_events; QVector<quint64> m_events;
const FunctionCall *m_call; const FunctionCall *m_call = nullptr;
const ParseData *m_data; const ParseData *m_data = nullptr;
qint64 m_differingFileId; qint64 m_differingFileId = -1;
}; };
CostItem::Private::Private(ParseData *data) CostItem::Private::Private(ParseData *data)
: m_positions(data->positions().size(), 0) : m_positions(data->positions().size(), 0)
, m_events(data->events().size(), 0) , m_events(data->events().size(), 0)
, m_call(0)
, m_data(data) , m_data(data)
, m_differingFileId(-1)
{ {
} }

View File

@@ -40,8 +40,6 @@ namespace Internal {
CycleDetection::CycleDetection(ParseData *data) CycleDetection::CycleDetection(ParseData *data)
: m_data(data) : m_data(data)
, m_depth(0)
, m_cycle(0)
{ {
} }
@@ -87,7 +85,7 @@ void CycleDetection::tarjan(Node *node)
m_ret.append(node->function); m_ret.append(node->function);
} else { } else {
// actual cycle // actual cycle
FunctionCycle *cycle = new FunctionCycle(m_data); auto cycle = new FunctionCycle(m_data);
cycle->setFile(node->function->fileId()); cycle->setFile(node->function->fileId());
m_cycle++; m_cycle++;
qint64 id = -1; qint64 id = -1;

View File

@@ -65,9 +65,9 @@ private:
QHash<const Function *, Node *> m_nodes; QHash<const Function *, Node *> m_nodes;
QStack<Node *> m_stack; QStack<Node *> m_stack;
QVector<const Function *> m_ret; QVector<const Function *> m_ret;
int m_depth; int m_depth = 0;
int m_cycle; int m_cycle = 0;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -46,7 +46,7 @@ class DataModel::Private
public: public:
void updateFunctions(); void updateFunctions();
const ParseData *m_data = 0; const ParseData *m_data = nullptr;
int m_event = 0; int m_event = 0;
bool m_verboseToolTips = true; bool m_verboseToolTips = true;
bool m_cycleDetection = false; bool m_cycleDetection = false;

View File

@@ -38,24 +38,14 @@ namespace Callgrind {
class FunctionCall::Private class FunctionCall::Private
{ {
public: public:
explicit Private(); const Function *m_callee = nullptr;
const Function *m_caller = nullptr;
const Function *m_callee; quint64 m_calls = 0;
const Function *m_caller; quint64 m_totalInclusiveCost = 0;
quint64 m_calls;
quint64 m_totalInclusiveCost;
QVector<quint64> m_destinations; QVector<quint64> m_destinations;
QVector<quint64> m_costs; QVector<quint64> m_costs;
}; };
FunctionCall::Private::Private()
: m_callee(0)
, m_caller(0)
, m_calls(0)
, m_totalInclusiveCost(0)
{
}
//BEGIN FunctionCall //BEGIN FunctionCall
FunctionCall::FunctionCall() FunctionCall::FunctionCall()

View File

@@ -58,10 +58,8 @@ FunctionCycle::FunctionCycle(const ParseData *data)
{ {
} }
FunctionCycle::~FunctionCycle()
{
// d should be deleted by Function::~Function() // d should be deleted by Function::~Function()
} FunctionCycle::~FunctionCycle() = default;
void FunctionCycle::setFunctions(const QVector<const Function *> &functions) void FunctionCycle::setFunctions(const QVector<const Function *> &functions)
{ {

View File

@@ -42,7 +42,7 @@ class FunctionCycle : public Function
{ {
public: public:
explicit FunctionCycle(const ParseData *data); explicit FunctionCycle(const ParseData *data);
virtual ~FunctionCycle(); ~FunctionCycle() override;
/// sets the list of functions that make up this cycle /// sets the list of functions that make up this cycle
/// NOTE: ownership is *not* transferred to the cycle /// NOTE: ownership is *not* transferred to the cycle

View File

@@ -68,7 +68,7 @@ public:
QHash<qint64, QHash<qint64, QVector<Function *> > > functionLookup; QHash<qint64, QHash<qint64, QVector<Function *> > > functionLookup;
typedef QHash<qint64, QString> NameLookupTable; using NameLookupTable = QHash<qint64, QString>;
QString stringForCompression(const NameLookupTable &lookup, qint64 id); QString stringForCompression(const NameLookupTable &lookup, qint64 id);
void addCompressedString(NameLookupTable &lookup, const QString &string, qint64 &id); void addCompressedString(NameLookupTable &lookup, const QString &string, qint64 &id);

View File

@@ -152,7 +152,7 @@ public:
void parse(QIODevice *device); void parse(QIODevice *device);
void parseHeader(QIODevice *device); void parseHeader(QIODevice *device);
typedef QPair<qint64, QString> NamePair; using NamePair = QPair<qint64, QString>;
NamePair parseName(const char *begin, const char *end); NamePair parseName(const char *begin, const char *end);
void dispatchLine(const QByteArray &line); void dispatchLine(const QByteArray &line);
@@ -252,7 +252,7 @@ void Parser::Private::parse(QIODevice *device)
callData.call->setCallee(calledFunction); callData.call->setCallee(calledFunction);
calledFunction->addIncomingCall(callData.call); calledFunction->addIncomingCall(callData.call);
Function *caller = const_cast<Function *>(callData.call->caller()); auto caller = const_cast<Function *>(callData.call->caller());
caller->addOutgoingCall(callData.call); caller->addOutgoingCall(callData.call);
pendingFunctions.insert(caller); pendingFunctions.insert(caller);
} }
@@ -440,9 +440,9 @@ void Parser::Private::parseCostItem(const char *begin, const char *end)
const char *current = begin; const char *current = begin;
QTC_ASSERT(currentDifferingFile == -1 || currentDifferingFile != currentFunction->fileId(), return); QTC_ASSERT(currentDifferingFile == -1 || currentDifferingFile != currentFunction->fileId(), return);
CostItem *costItem = new CostItem(data); auto costItem = new CostItem(data);
costItem->setDifferingFile(currentDifferingFile); costItem->setDifferingFile(currentDifferingFile);
FunctionCall *call = 0; FunctionCall *call = nullptr;
if (isParsingFunctionCall) { if (isParsingFunctionCall) {
call = new FunctionCall; call = new FunctionCall;
call->setCaller(currentFunction); call->setCaller(currentFunction);
@@ -477,7 +477,7 @@ void Parser::Private::parseCostItem(const char *begin, const char *end)
currentCallData = CallData(); currentCallData = CallData();
} }
const CostItem *lastCostItem = 0; const CostItem *lastCostItem = nullptr;
if (!currentFunction->costItems().isEmpty()) if (!currentFunction->costItems().isEmpty())
lastCostItem = currentFunction->costItems().last(); lastCostItem = currentFunction->costItems().last();
@@ -652,7 +652,7 @@ Parser::~Parser()
ParseData *Parser::takeData() ParseData *Parser::takeData()
{ {
ParseData *data = d->data; ParseData *data = d->data;
d->data = 0; d->data = nullptr;
return data; return data;
} }

View File

@@ -39,9 +39,6 @@ namespace Callgrind {
DataProxyModel::DataProxyModel(QObject *parent) DataProxyModel::DataProxyModel(QObject *parent)
: QSortFilterProxyModel(parent) : QSortFilterProxyModel(parent)
, m_function(0)
, m_maxRows(0)
, m_minimumInclusiveCostRatio(0.0)
{ {
setDynamicSortFilter(true); setDynamicSortFilter(true);
} }
@@ -119,7 +116,7 @@ bool DataProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_
if (m_maxRows > 0 && source_row > m_maxRows) if (m_maxRows > 0 && source_row > m_maxRows)
return false; return false;
const Function *func = source_index.data(DataModel::FunctionRole).value<const Function *>(); auto func = source_index.data(DataModel::FunctionRole).value<const Function *>();
if (!func) if (!func)
return false; return false;

View File

@@ -69,9 +69,9 @@ private:
DataModel *dataModel() const; DataModel *dataModel() const;
QString m_baseDir; QString m_baseDir;
const Function *m_function; const Function *m_function = nullptr;
int m_maxRows; int m_maxRows = 0;
double m_minimumInclusiveCostRatio; double m_minimumInclusiveCostRatio = 0;
}; };
} // namespace Callgrind } // namespace Callgrind

View File

@@ -44,20 +44,13 @@ namespace Internal {
class CostDelegate::Private class CostDelegate::Private
{ {
public: public:
Private(); QAbstractItemModel *m_model = nullptr;
CostDelegate::CostFormat m_format = CostDelegate::FormatAbsolute;
QAbstractItemModel *m_model;
CostDelegate::CostFormat m_format;
float relativeCost(const QModelIndex &index) const; float relativeCost(const QModelIndex &index) const;
QString displayText(const QModelIndex &index, const QLocale &locale) const; QString displayText(const QModelIndex &index, const QLocale &locale) const;
}; };
CostDelegate::Private::Private()
: m_model(0)
, m_format(CostDelegate::FormatAbsolute)
{}
static int toNativeRole(CostDelegate::CostFormat format) static int toNativeRole(CostDelegate::CostFormat format)
{ {
switch (format) switch (format)
@@ -145,7 +138,7 @@ void CostDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
// Draw text. // Draw text.
QLocale loc = opt.locale; QLocale loc = opt.locale;
loc.setNumberOptions(0); loc.setNumberOptions(nullptr);
const QString text = d->displayText(index, loc); const QString text = d->displayText(index, loc);
const QBrush &textBrush = (option.state & QStyle::State_Selected ? opt.palette.highlightedText() : opt.palette.text()); const QBrush &textBrush = (option.state & QStyle::State_Selected ? opt.palette.highlightedText() : opt.palette.text());
painter->setBrush(Qt::NoBrush); painter->setBrush(Qt::NoBrush);

View File

@@ -33,12 +33,12 @@ namespace Internal {
class CostDelegate : public QStyledItemDelegate class CostDelegate : public QStyledItemDelegate
{ {
public: public:
explicit CostDelegate(QObject *parent = 0); explicit CostDelegate(QObject *parent = nullptr);
virtual ~CostDelegate(); ~CostDelegate() override;
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const; const QModelIndex &index) const override;
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setModel(QAbstractItemModel *model); void setModel(QAbstractItemModel *model);

View File

@@ -55,16 +55,14 @@ CostView::CostView(QWidget *parent)
setRootIsDecorated(false); setRootIsDecorated(false);
} }
CostView::~CostView() CostView::~CostView() = default;
{
}
void CostView::setModel(QAbstractItemModel *model) void CostView::setModel(QAbstractItemModel *model)
{ {
QTreeView::setModel(model); BaseTreeView::setModel(model);
forever { forever {
QAbstractProxyModel *proxy = qobject_cast<QAbstractProxyModel *>(model); auto proxy = qobject_cast<const QAbstractProxyModel *>(model);
if (!proxy) if (!proxy)
break; break;
model = proxy->sourceModel(); model = proxy->sourceModel();

View File

@@ -40,14 +40,14 @@ class CostView : public Utils::BaseTreeView
Q_OBJECT Q_OBJECT
public: public:
explicit CostView(QWidget *parent = 0); explicit CostView(QWidget *parent = nullptr);
~CostView(); ~CostView() override;
/** /**
* Overload automatically updates the cost delegate * Overload automatically updates the cost delegate
* and sets it for the cost columns of DataModel and CallModel. * and sets it for the cost columns of DataModel and CallModel.
*/ */
void setModel(QAbstractItemModel *model); void setModel(QAbstractItemModel *model) override;
/** /**
* How to format cost data columns in the view. * How to format cost data columns in the view.

View File

@@ -33,10 +33,10 @@ namespace Internal {
class NameDelegate : public QStyledItemDelegate class NameDelegate : public QStyledItemDelegate
{ {
public: public:
explicit NameDelegate(QObject *parent = 0); explicit NameDelegate(QObject *parent = nullptr);
void paint(QPainter *painter, const QStyleOptionViewItem &option, void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const; const QModelIndex &index) const override;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -92,7 +92,7 @@ void CallgrindTextMark::paintIcon(QPainter *painter, const QRect &paintRect) con
const Function *CallgrindTextMark::function() const const Function *CallgrindTextMark::function() const
{ {
if (!m_modelIndex.isValid()) if (!m_modelIndex.isValid())
return 0; return nullptr;
return m_modelIndex.data(DataModel::FunctionRole).value<const Function *>(); return m_modelIndex.data(DataModel::FunctionRole).value<const Function *>();
} }

View File

@@ -49,7 +49,7 @@ public:
const Valgrind::Callgrind::Function *function() const; const Valgrind::Callgrind::Function *function() const;
virtual void paintIcon(QPainter *painter, const QRect &paintRect) const; void paintIcon(QPainter *painter, const QRect &paintRect) const override;
private: private:
QPersistentModelIndex m_modelIndex; QPersistentModelIndex m_modelIndex;

View File

@@ -112,7 +112,7 @@ class CallgrindTool : public QObject
public: public:
CallgrindTool(); CallgrindTool();
~CallgrindTool(); ~CallgrindTool() override;
void setupRunner(CallgrindToolRunner *runner); void setupRunner(CallgrindToolRunner *runner);
@@ -682,7 +682,7 @@ void CallgrindTool::handleFilterProjectCosts()
void CallgrindTool::dataFunctionSelected(const QModelIndex &index) void CallgrindTool::dataFunctionSelected(const QModelIndex &index)
{ {
const Function *func = index.data(DataModel::FunctionRole).value<const Function *>(); auto func = index.data(DataModel::FunctionRole).value<const Function *>();
QTC_ASSERT(func, return); QTC_ASSERT(func, return);
selectFunction(func); selectFunction(func);
@@ -690,7 +690,7 @@ void CallgrindTool::dataFunctionSelected(const QModelIndex &index)
void CallgrindTool::calleeFunctionSelected(const QModelIndex &index) void CallgrindTool::calleeFunctionSelected(const QModelIndex &index)
{ {
const FunctionCall *call = index.data(CallModel::FunctionCallRole).value<const FunctionCall *>(); auto call = index.data(CallModel::FunctionCallRole).value<const FunctionCall *>();
QTC_ASSERT(call, return); QTC_ASSERT(call, return);
selectFunction(call->callee()); selectFunction(call->callee());
@@ -698,7 +698,7 @@ void CallgrindTool::calleeFunctionSelected(const QModelIndex &index)
void CallgrindTool::callerFunctionSelected(const QModelIndex &index) void CallgrindTool::callerFunctionSelected(const QModelIndex &index)
{ {
const FunctionCall *call = index.data(CallModel::FunctionCallRole).value<const FunctionCall *>(); auto call = index.data(CallModel::FunctionCallRole).value<const FunctionCall *>();
QTC_ASSERT(call, return); QTC_ASSERT(call, return);
selectFunction(call->caller()); selectFunction(call->caller());

View File

@@ -80,14 +80,14 @@ public:
}; };
FunctionGraphicsItem(const QString &text, qreal x, qreal y, FunctionGraphicsItem(const QString &text, qreal x, qreal y,
qreal width, qreal height, QGraphicsItem *parent = 0); qreal width, qreal height, QGraphicsItem *parent = nullptr);
void paint(QPainter *painter, void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget) override; const QStyleOptionGraphicsItem *option, QWidget *widget) override;
FunctionGraphicsTextItem *textItem() const; FunctionGraphicsTextItem *textItem() const;
private: private:
FunctionGraphicsTextItem *m_text; FunctionGraphicsTextItem *m_text = nullptr;
}; };
FunctionGraphicsTextItem::FunctionGraphicsTextItem(const QString &text, FunctionGraphicsTextItem::FunctionGraphicsTextItem(const QString &text,
@@ -97,7 +97,7 @@ FunctionGraphicsTextItem::FunctionGraphicsTextItem(const QString &text,
, m_previousViewportDimension(0) , m_previousViewportDimension(0)
{ {
setFlag(QGraphicsItem::ItemIgnoresTransformations); setFlag(QGraphicsItem::ItemIgnoresTransformations);
setAcceptedMouseButtons(0); // do not steal focus from parent item setAcceptedMouseButtons(nullptr); // do not steal focus from parent item
setToolTip(text); setToolTip(text);
} }
@@ -155,7 +155,6 @@ QRectF FunctionGraphicsTextItem::boundingRect() const
FunctionGraphicsItem::FunctionGraphicsItem(const QString &text, FunctionGraphicsItem::FunctionGraphicsItem(const QString &text,
qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent) qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent)
: QGraphicsRectItem(x, y, width, height, parent) : QGraphicsRectItem(x, y, width, height, parent)
, m_text(0)
{ {
setFlag(QGraphicsItem::ItemIsSelectable); setFlag(QGraphicsItem::ItemIsSelectable);
setFlag(QGraphicsItem::ItemClipsToShape); setFlag(QGraphicsItem::ItemClipsToShape);
@@ -237,7 +236,7 @@ void Visualization::Private::handleMousePressEvent(QMouseEvent *event,
bool doubleClicked) bool doubleClicked)
{ {
// find the first item that accepts mouse presses under the cursor position // find the first item that accepts mouse presses under the cursor position
QGraphicsItem *itemAtPos = 0; QGraphicsItem *itemAtPos = nullptr;
foreach (QGraphicsItem *item, q->items(event->pos())) { foreach (QGraphicsItem *item, q->items(event->pos())) {
if (!(item->acceptedMouseButtons() & event->button())) if (!(item->acceptedMouseButtons() & event->button()))
continue; continue;
@@ -297,7 +296,7 @@ QGraphicsItem *Visualization::itemForFunction(const Function *function) const
if (functionForItem(item) == function) if (functionForItem(item) == function)
return item; return item;
} }
return 0; return nullptr;
} }
void Visualization::setFunction(const Function *function) void Visualization::setFunction(const Function *function)
@@ -364,7 +363,7 @@ void Visualization::populateScene()
// cache costs of each element, calculate total costs // cache costs of each element, calculate total costs
qreal total = 0; qreal total = 0;
typedef QPair<QModelIndex, qreal> Pair; using Pair = QPair<QModelIndex, qreal>;
QLinkedList<Pair> costs; QLinkedList<Pair> costs;
for (int row = 0; row < d->m_model->rowCount(); ++row) { for (int row = 0; row < d->m_model->rowCount(); ++row) {
const QModelIndex index = d->m_model->index(row, DataModel::InclusiveCostColumn); const QModelIndex index = d->m_model->index(row, DataModel::InclusiveCostColumn);
@@ -392,7 +391,7 @@ void Visualization::populateScene()
} }
const qreal height = sceneHeight * (costs.isEmpty() ? 1.0 : 0.1); const qreal height = sceneHeight * (costs.isEmpty() ? 1.0 : 0.1);
FunctionGraphicsItem *item = new FunctionGraphicsItem(text, 0, 0, sceneWidth, height); auto item = new FunctionGraphicsItem(text, 0, 0, sceneWidth, height);
const QColor background = CallgrindHelper::colorForString(text); const QColor background = CallgrindHelper::colorForString(text);
item->setBrush(background); item->setBrush(background);
item->setData(FunctionGraphicsItem::FunctionCallKey, QVariant::fromValue(d->m_model->filterFunction())); item->setData(FunctionGraphicsItem::FunctionCallKey, QVariant::fromValue(d->m_model->filterFunction()));
@@ -409,7 +408,7 @@ void Visualization::populateScene()
const qreal height = (sceneHeight * 0.9 * cost.second) / total; const qreal height = (sceneHeight * 0.9 * cost.second) / total;
FunctionGraphicsItem *item = new FunctionGraphicsItem(text, 0, used, sceneWidth, height); auto item = new FunctionGraphicsItem(text, 0, used, sceneWidth, height);
const QColor background = CallgrindHelper::colorForString(text); const QColor background = CallgrindHelper::colorForString(text);
item->setBrush(background); item->setBrush(background);
item->setData(FunctionGraphicsItem::FunctionCallKey, index.data(DataModel::FunctionRole)); item->setData(FunctionGraphicsItem::FunctionCallKey, index.data(DataModel::FunctionRole));

View File

@@ -43,8 +43,8 @@ class Visualization : public QGraphicsView
Q_OBJECT Q_OBJECT
public: public:
explicit Visualization(QWidget *parent = 0); explicit Visualization(QWidget *parent = nullptr);
virtual ~Visualization(); ~Visualization() override;
void setModel(QAbstractItemModel *model); void setModel(QAbstractItemModel *model);
@@ -64,9 +64,9 @@ signals:
protected: protected:
void populateScene(); void populateScene();
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event); void mouseDoubleClickEvent(QMouseEvent *event) override;
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event) override;
private: private:
class Private; class Private;

View File

@@ -52,8 +52,7 @@ namespace Valgrind {
namespace Internal { namespace Internal {
MemcheckErrorView::MemcheckErrorView(QWidget *parent) MemcheckErrorView::MemcheckErrorView(QWidget *parent)
: Debugger::DetailedErrorView(parent), : Debugger::DetailedErrorView(parent)
m_settings(0)
{ {
m_suppressAction = new QAction(this); m_suppressAction = new QAction(this);
m_suppressAction->setText(tr("Suppress Error")); m_suppressAction->setText(tr("Suppress Error"));
@@ -68,9 +67,7 @@ MemcheckErrorView::MemcheckErrorView(QWidget *parent)
addAction(m_suppressAction); addAction(m_suppressAction);
} }
MemcheckErrorView::~MemcheckErrorView() MemcheckErrorView::~MemcheckErrorView() = default;
{
}
void MemcheckErrorView::setDefaultSuppressionFile(const QString &suppFile) void MemcheckErrorView::setDefaultSuppressionFile(const QString &suppFile)
{ {

View File

@@ -40,8 +40,8 @@ class MemcheckErrorView : public Debugger::DetailedErrorView
Q_OBJECT Q_OBJECT
public: public:
MemcheckErrorView(QWidget *parent = 0); MemcheckErrorView(QWidget *parent = nullptr);
~MemcheckErrorView(); ~MemcheckErrorView() override;
void setDefaultSuppressionFile(const QString &suppFile); void setDefaultSuppressionFile(const QString &suppFile);
QString defaultSuppressionFile() const; QString defaultSuppressionFile() const;
@@ -54,7 +54,7 @@ private:
QAction *m_suppressAction; QAction *m_suppressAction;
QString m_defaultSuppFile; QString m_defaultSuppFile;
ValgrindBaseSettings *m_settings; ValgrindBaseSettings *m_settings = nullptr;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -294,7 +294,7 @@ class MemcheckErrorFilterProxyModel : public QSortFilterProxyModel
public: public:
void setAcceptedKinds(const QList<int> &acceptedKinds); void setAcceptedKinds(const QList<int> &acceptedKinds);
void setFilterExternalIssues(bool filter); void setFilterExternalIssues(bool filter);
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
private: private:
QList<int> m_acceptedKinds; QList<int> m_acceptedKinds;
@@ -388,7 +388,7 @@ class MemcheckTool : public QObject
public: public:
MemcheckTool(); MemcheckTool();
~MemcheckTool(); ~MemcheckTool() override;
void setupRunner(MemcheckToolRunner *runTool); void setupRunner(MemcheckToolRunner *runTool);
void loadShowXmlLogFile(const QString &filePath, const QString &exitMsg); void loadShowXmlLogFile(const QString &filePath, const QString &exitMsg);
@@ -418,7 +418,7 @@ private:
private: private:
ValgrindBaseSettings *m_settings; ValgrindBaseSettings *m_settings;
QMenu *m_filterMenu = 0; QMenu *m_filterMenu = nullptr;
Valgrind::XmlProtocol::ErrorListModel m_errorModel; Valgrind::XmlProtocol::ErrorListModel m_errorModel;
MemcheckErrorFilterProxyModel m_errorProxyModel; MemcheckErrorFilterProxyModel m_errorProxyModel;
@@ -453,7 +453,7 @@ public:
bool attach() const; bool attach() const;
QString path() const; QString path() const;
void keyPressEvent(QKeyEvent *e); void keyPressEvent(QKeyEvent *e) override;
private: private:
void updateEnabled(); void updateEnabled();
@@ -479,7 +479,7 @@ class HeobData : public QObject
public: public:
HeobData(MemcheckTool *mcTool, const QString &xmlPath, Kit *kit, bool attach); HeobData(MemcheckTool *mcTool, const QString &xmlPath, Kit *kit, bool attach);
~HeobData(); ~HeobData() override;
bool createErrorPipe(DWORD heobPid); bool createErrorPipe(DWORD heobPid);
void readExitData(); void readExitData();
@@ -829,7 +829,7 @@ void MemcheckTool::heobAction()
memset(&si, 0, sizeof(STARTUPINFO)); memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO); si.cb = sizeof(STARTUPINFO);
if (!CreateProcess(reinterpret_cast<LPCWSTR>(heobPath.utf16()), if (!CreateProcess(reinterpret_cast<LPCWSTR>(heobPath.utf16()),
reinterpret_cast<LPWSTR>(argumentsCopy.data()), 0, 0, FALSE, reinterpret_cast<LPWSTR>(argumentsCopy.data()), NULL, NULL, FALSE,
CREATE_UNICODE_ENVIRONMENT | CREATE_SUSPENDED | CREATE_NEW_CONSOLE, envPtr, CREATE_UNICODE_ENVIRONMENT | CREATE_SUSPENDED | CREATE_NEW_CONSOLE, envPtr,
reinterpret_cast<LPCWSTR>(workingDirectory.utf16()), &si, &pi)) { reinterpret_cast<LPCWSTR>(workingDirectory.utf16()), &si, &pi)) {
DWORD e = GetLastError(); DWORD e = GetLastError();
@@ -840,7 +840,7 @@ void MemcheckTool::heobAction()
} }
// heob finished signal handler // heob finished signal handler
HeobData *hd = new HeobData(this, xmlPath, kit, dialog.attach()); auto hd = new HeobData(this, xmlPath, kit, dialog.attach());
if (!hd->createErrorPipe(pi.dwProcessId)) { if (!hd->createErrorPipe(pi.dwProcessId)) {
delete hd; delete hd;
hd = nullptr; hd = nullptr;
@@ -911,7 +911,7 @@ void MemcheckTool::maybeActiveRunConfigurationChanged()
{ {
updateRunActions(); updateRunActions();
ValgrindBaseSettings *settings = 0; ValgrindBaseSettings *settings = nullptr;
if (Project *project = SessionManager::startupProject()) if (Project *project = SessionManager::startupProject())
if (Target *target = project->activeTarget()) if (Target *target = project->activeTarget())
if (RunConfiguration *rc = target->activeRunConfiguration()) if (RunConfiguration *rc = target->activeRunConfiguration())
@@ -1000,7 +1000,7 @@ void MemcheckTool::loadExternalXmlLogFile()
void MemcheckTool::loadXmlLogFile(const QString &filePath) void MemcheckTool::loadXmlLogFile(const QString &filePath)
{ {
QFile *logFile = new QFile(filePath); auto logFile = new QFile(filePath);
if (!logFile->open(QIODevice::ReadOnly | QIODevice::Text)) { if (!logFile->open(QIODevice::ReadOnly | QIODevice::Text)) {
delete logFile; delete logFile;
QString msg = tr("Memcheck: Failed to open file for reading: %1").arg(filePath); QString msg = tr("Memcheck: Failed to open file for reading: %1").arg(filePath);
@@ -1021,7 +1021,7 @@ void MemcheckTool::loadXmlLogFile(const QString &filePath)
updateFromSettings(); updateFromSettings();
} }
ThreadedParser *parser = new ThreadedParser; auto parser = new ThreadedParser;
connect(parser, &ThreadedParser::error, this, &MemcheckTool::parserError); connect(parser, &ThreadedParser::error, this, &MemcheckTool::parserError);
connect(parser, &ThreadedParser::internalError, this, &MemcheckTool::internalParserError); connect(parser, &ThreadedParser::internalError, this, &MemcheckTool::internalParserError);
connect(parser, &ThreadedParser::finished, this, &MemcheckTool::loadingExternalXmlLogFileFinished); connect(parser, &ThreadedParser::finished, this, &MemcheckTool::loadingExternalXmlLogFileFinished);
@@ -1090,13 +1090,13 @@ void MemcheckTool::engineFinished()
const int issuesFound = updateUiAfterFinishedHelper(); const int issuesFound = updateUiAfterFinishedHelper();
Debugger::showPermanentStatusMessage( Debugger::showPermanentStatusMessage(
tr("Memory Analyzer Tool finished. %n issues were found.", 0, issuesFound)); tr("Memory Analyzer Tool finished. %n issues were found.", nullptr, issuesFound));
} }
void MemcheckTool::loadingExternalXmlLogFileFinished() void MemcheckTool::loadingExternalXmlLogFileFinished()
{ {
const int issuesFound = updateUiAfterFinishedHelper(); const int issuesFound = updateUiAfterFinishedHelper();
QString statusMessage = tr("Log file processed. %n issues were found.", 0, issuesFound); QString statusMessage = tr("Log file processed. %n issues were found.", nullptr, issuesFound);
if (!m_exitMsg.isEmpty()) if (!m_exitMsg.isEmpty())
statusMessage += ' ' + m_exitMsg; statusMessage += ' ' + m_exitMsg;
Debugger::showPermanentStatusMessage(statusMessage); Debugger::showPermanentStatusMessage(statusMessage);
@@ -1195,20 +1195,20 @@ HeobDialog::HeobDialog(QWidget *parent) :
path = QFileInfo(heobPath).path(); path = QFileInfo(heobPath).path();
} }
QVBoxLayout *layout = new QVBoxLayout; auto layout = new QVBoxLayout;
// disable resizing // disable resizing
layout->setSizeConstraint(QLayout::SetFixedSize); layout->setSizeConstraint(QLayout::SetFixedSize);
QHBoxLayout *xmlLayout = new QHBoxLayout; auto xmlLayout = new QHBoxLayout;
QLabel *xmlLabel = new QLabel(tr("XML output file:")); auto xmlLabel = new QLabel(tr("XML output file:"));
xmlLayout->addWidget(xmlLabel); xmlLayout->addWidget(xmlLabel);
m_xmlEdit = new QLineEdit; m_xmlEdit = new QLineEdit;
m_xmlEdit->setText(xml); m_xmlEdit->setText(xml);
xmlLayout->addWidget(m_xmlEdit); xmlLayout->addWidget(m_xmlEdit);
layout->addLayout(xmlLayout); layout->addLayout(xmlLayout);
QHBoxLayout *handleExceptionLayout = new QHBoxLayout; auto handleExceptionLayout = new QHBoxLayout;
QLabel *handleExceptionLabel = new QLabel(tr("Handle exceptions:")); auto handleExceptionLabel = new QLabel(tr("Handle exceptions:"));
handleExceptionLayout->addWidget(handleExceptionLabel); handleExceptionLayout->addWidget(handleExceptionLabel);
m_handleExceptionCombo = new QComboBox; m_handleExceptionCombo = new QComboBox;
m_handleExceptionCombo->addItem(tr("Off")); m_handleExceptionCombo->addItem(tr("Off"));
@@ -1220,8 +1220,8 @@ HeobDialog::HeobDialog(QWidget *parent) :
handleExceptionLayout->addWidget(m_handleExceptionCombo); handleExceptionLayout->addWidget(m_handleExceptionCombo);
layout->addLayout(handleExceptionLayout); layout->addLayout(handleExceptionLayout);
QHBoxLayout *pageProtectionLayout = new QHBoxLayout; auto pageProtectionLayout = new QHBoxLayout;
QLabel *pageProtectionLabel = new QLabel(tr("Page protection:")); auto pageProtectionLabel = new QLabel(tr("Page protection:"));
pageProtectionLayout->addWidget(pageProtectionLabel); pageProtectionLayout->addWidget(pageProtectionLabel);
m_pageProtectionCombo = new QComboBox; m_pageProtectionCombo = new QComboBox;
m_pageProtectionCombo->addItem(tr("Off")); m_pageProtectionCombo->addItem(tr("Off"));
@@ -1241,8 +1241,8 @@ HeobDialog::HeobDialog(QWidget *parent) :
m_breakpointCheck->setChecked(breakpoint); m_breakpointCheck->setChecked(breakpoint);
layout->addWidget(m_breakpointCheck); layout->addWidget(m_breakpointCheck);
QHBoxLayout *leakDetailLayout = new QHBoxLayout; auto leakDetailLayout = new QHBoxLayout;
QLabel *leakDetailLabel = new QLabel(tr("Leak details:")); auto leakDetailLabel = new QLabel(tr("Leak details:"));
leakDetailLayout->addWidget(leakDetailLabel); leakDetailLayout->addWidget(leakDetailLabel);
m_leakDetailCombo = new QComboBox; m_leakDetailCombo = new QComboBox;
m_leakDetailCombo->addItem(tr("None")); m_leakDetailCombo->addItem(tr("None"));
@@ -1257,8 +1257,8 @@ HeobDialog::HeobDialog(QWidget *parent) :
leakDetailLayout->addWidget(m_leakDetailCombo); leakDetailLayout->addWidget(m_leakDetailCombo);
layout->addLayout(leakDetailLayout); layout->addLayout(leakDetailLayout);
QHBoxLayout *leakSizeLayout = new QHBoxLayout; auto leakSizeLayout = new QHBoxLayout;
QLabel *leakSizeLabel = new QLabel(tr("Minimum leak size:")); auto leakSizeLabel = new QLabel(tr("Minimum leak size:"));
leakSizeLayout->addWidget(leakSizeLabel); leakSizeLayout->addWidget(leakSizeLabel);
m_leakSizeSpin = new QSpinBox; m_leakSizeSpin = new QSpinBox;
m_leakSizeSpin->setMinimum(0); m_leakSizeSpin->setMinimum(0);
@@ -1268,8 +1268,8 @@ HeobDialog::HeobDialog(QWidget *parent) :
leakSizeLayout->addWidget(m_leakSizeSpin); leakSizeLayout->addWidget(m_leakSizeSpin);
layout->addLayout(leakSizeLayout); layout->addLayout(leakSizeLayout);
QHBoxLayout *leakRecordingLayout = new QHBoxLayout; auto leakRecordingLayout = new QHBoxLayout;
QLabel *leakRecordingLabel = new QLabel(tr("Control leak recording:")); auto leakRecordingLabel = new QLabel(tr("Control leak recording:"));
leakRecordingLayout->addWidget(leakRecordingLabel); leakRecordingLayout->addWidget(leakRecordingLabel);
m_leakRecordingCombo = new QComboBox; m_leakRecordingCombo = new QComboBox;
m_leakRecordingCombo->addItem(tr("Off")); m_leakRecordingCombo->addItem(tr("Off"));
@@ -1283,16 +1283,16 @@ HeobDialog::HeobDialog(QWidget *parent) :
m_attachCheck->setChecked(attach); m_attachCheck->setChecked(attach);
layout->addWidget(m_attachCheck); layout->addWidget(m_attachCheck);
QHBoxLayout *extraArgsLayout = new QHBoxLayout; auto extraArgsLayout = new QHBoxLayout;
QLabel *extraArgsLabel = new QLabel(tr("Extra arguments:")); auto extraArgsLabel = new QLabel(tr("Extra arguments:"));
extraArgsLayout->addWidget(extraArgsLabel); extraArgsLayout->addWidget(extraArgsLabel);
m_extraArgsEdit = new QLineEdit; m_extraArgsEdit = new QLineEdit;
m_extraArgsEdit->setText(extraArgs); m_extraArgsEdit->setText(extraArgs);
extraArgsLayout->addWidget(m_extraArgsEdit); extraArgsLayout->addWidget(m_extraArgsEdit);
layout->addLayout(extraArgsLayout); layout->addLayout(extraArgsLayout);
QHBoxLayout *pathLayout = new QHBoxLayout; auto pathLayout = new QHBoxLayout;
QLabel *pathLabel = new QLabel(tr("Heob path:")); auto pathLabel = new QLabel(tr("Heob path:"));
pathLabel->setToolTip(tr("The location of heob32.exe and heob64.exe.")); pathLabel->setToolTip(tr("The location of heob32.exe and heob64.exe."));
pathLayout->addWidget(pathLabel); pathLayout->addWidget(pathLabel);
m_pathChooser = new PathChooser; m_pathChooser = new PathChooser;
@@ -1300,18 +1300,18 @@ HeobDialog::HeobDialog(QWidget *parent) :
pathLayout->addWidget(m_pathChooser); pathLayout->addWidget(m_pathChooser);
layout->addLayout(pathLayout); layout->addLayout(pathLayout);
QHBoxLayout *saveLayout = new QHBoxLayout; auto saveLayout = new QHBoxLayout;
saveLayout->addStretch(1); saveLayout->addStretch(1);
QToolButton *saveButton = new QToolButton; auto saveButton = new QToolButton;
saveButton->setToolTip(tr("Save current settings as default.")); saveButton->setToolTip(tr("Save current settings as default."));
saveButton->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton)); saveButton->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
connect(saveButton, &QAbstractButton::clicked, this, &HeobDialog::saveOptions); connect(saveButton, &QAbstractButton::clicked, this, &HeobDialog::saveOptions);
saveLayout->addWidget(saveButton); saveLayout->addWidget(saveButton);
layout->addLayout(saveLayout); layout->addLayout(saveLayout);
QHBoxLayout *okLayout = new QHBoxLayout; auto okLayout = new QHBoxLayout;
okLayout->addStretch(1); okLayout->addStretch(1);
QPushButton *okButton = new QPushButton(tr("OK")); auto okButton = new QPushButton(tr("OK"));
okButton->setDefault(true); okButton->setDefault(true);
connect(okButton, &QAbstractButton::clicked, this, &QDialog::accept); connect(okButton, &QAbstractButton::clicked, this, &QDialog::accept);
okLayout->addWidget(okButton); okLayout->addWidget(okButton);

View File

@@ -123,9 +123,9 @@ SuppressionDialog::SuppressionDialog(MemcheckErrorView *view, const QList<Error>
{ {
setWindowTitle(tr("Save Suppression")); setWindowTitle(tr("Save Suppression"));
QLabel *fileLabel = new QLabel(tr("Suppression File:"), this); auto fileLabel = new QLabel(tr("Suppression File:"), this);
QLabel *suppressionsLabel = new QLabel(tr("Suppression:"), this); auto suppressionsLabel = new QLabel(tr("Suppression:"), this);
suppressionsLabel->setBuddy(m_suppressionEdit); suppressionsLabel->setBuddy(m_suppressionEdit);
QFont font; QFont font;
@@ -135,7 +135,7 @@ SuppressionDialog::SuppressionDialog(MemcheckErrorView *view, const QList<Error>
m_buttonBox = new QDialogButtonBox(this); m_buttonBox = new QDialogButtonBox(this);
m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Save); m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Save);
QFormLayout *formLayout = new QFormLayout(this); auto formLayout = new QFormLayout(this);
formLayout->addRow(fileLabel, m_fileChooser); formLayout->addRow(fileLabel, m_fileChooser);
formLayout->addRow(suppressionsLabel); formLayout->addRow(suppressionsLabel);
formLayout->addRow(m_suppressionEdit); formLayout->addRow(m_suppressionEdit);

View File

@@ -54,8 +54,8 @@ public:
private: private:
void validate(); void validate();
void accept(); void accept() override;
void reject(); void reject() override;
MemcheckErrorView *m_view; MemcheckErrorView *m_view;
ValgrindBaseSettings *m_settings; ValgrindBaseSettings *m_settings;

View File

@@ -151,7 +151,7 @@ ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings, bool
if (!global) { if (!global) {
// In project settings we want a flat vertical list. // In project settings we want a flat vertical list.
QVBoxLayout *l = new QVBoxLayout; auto l = new QVBoxLayout;
while (layout()->count()) { while (layout()->count()) {
QLayoutItem *item = layout()->takeAt(0); QLayoutItem *item = layout()->takeAt(0);
if (QWidget *w = item->widget()) if (QWidget *w = item->widget())

View File

@@ -45,7 +45,7 @@ class ValgrindConfigWidget : public QWidget
public: public:
ValgrindConfigWidget(ValgrindBaseSettings *settings, bool global); ValgrindConfigWidget(ValgrindBaseSettings *settings, bool global);
virtual ~ValgrindConfigWidget(); ~ValgrindConfigWidget() override;
void setSuppressions(const QStringList &files); void setSuppressions(const QStringList &files);
QStringList suppressions() const; QStringList suppressions() const;

View File

@@ -190,7 +190,7 @@ void ValgrindToolRunner::receiveProcessError(const QString &message, QProcess::P
return; return;
QObject *obj = ExtensionSystem::PluginManager::getObjectByName("AppOutputPane"); QObject *obj = ExtensionSystem::PluginManager::getObjectByName("AppOutputPane");
if (IOutputPane *pane = qobject_cast<IOutputPane *>(obj)) if (auto pane = qobject_cast<IOutputPane *>(obj))
pane->popup(IOutputPane::NoModeSwitch); pane->popup(IOutputPane::NoModeSwitch);
} }

View File

@@ -53,7 +53,7 @@ protected:
virtual QString progressTitle() const = 0; virtual QString progressTitle() const = 0;
virtual QStringList toolArguments() const = 0; virtual QStringList toolArguments() const = 0;
ValgrindBaseSettings *m_settings = 0; ValgrindBaseSettings *m_settings = nullptr;
QFutureInterface<void> m_progress; QFutureInterface<void> m_progress;
ValgrindRunner m_runner; ValgrindRunner m_runner;

View File

@@ -145,11 +145,11 @@ void ValgrindMemcheckParserTest::cleanup()
{ {
if (m_socket) { if (m_socket) {
delete m_socket; delete m_socket;
m_socket = 0; m_socket = nullptr;
} }
if (m_process) { if (m_process) {
delete m_process; delete m_process;
m_process = 0; m_process = nullptr;
} }
} }

View File

@@ -53,7 +53,7 @@ using namespace ProjectExplorer;
namespace Valgrind { namespace Valgrind {
namespace Internal { namespace Internal {
static ValgrindGlobalSettings *theGlobalSettings = 0; static ValgrindGlobalSettings *theGlobalSettings = nullptr;
class ValgrindOptionsPage : public IOptionsPage class ValgrindOptionsPage : public IOptionsPage
{ {
@@ -68,19 +68,19 @@ public:
setCategoryIcon(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER); setCategoryIcon(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
} }
QWidget *widget() QWidget *widget() override
{ {
if (!m_widget) if (!m_widget)
m_widget = new ValgrindConfigWidget(theGlobalSettings, true); m_widget = new ValgrindConfigWidget(theGlobalSettings, true);
return m_widget; return m_widget;
} }
void apply() void apply() override
{ {
theGlobalSettings->writeSettings(); theGlobalSettings->writeSettings();
} }
void finish() void finish() override
{ {
delete m_widget; delete m_widget;
} }
@@ -108,7 +108,7 @@ public:
ValgrindPlugin::~ValgrindPlugin() ValgrindPlugin::~ValgrindPlugin()
{ {
delete theGlobalSettings; delete theGlobalSettings;
theGlobalSettings = 0; theGlobalSettings = nullptr;
} }
bool ValgrindPlugin::initialize(const QStringList &, QString *) bool ValgrindPlugin::initialize(const QStringList &, QString *)

View File

@@ -40,7 +40,7 @@ class ValgrindPlugin : public ExtensionSystem::IPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Valgrind.json") Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Valgrind.json")
public: public:
ValgrindPlugin() {} ValgrindPlugin() = default;
~ValgrindPlugin() override; ~ValgrindPlugin() override;
bool initialize(const QStringList &arguments, QString *errorString) override; bool initialize(const QStringList &arguments, QString *errorString) override;

View File

@@ -224,7 +224,7 @@ ValgrindRunner::~ValgrindRunner()
waitForFinished(); waitForFinished();
} }
delete d; delete d;
d = 0; d = nullptr;
} }
void ValgrindRunner::setValgrindExecutable(const QString &executable) void ValgrindRunner::setValgrindExecutable(const QString &executable)

View File

@@ -114,7 +114,7 @@ void ValgrindTestRunnerTest::cleanup()
{ {
Q_ASSERT(m_runner); Q_ASSERT(m_runner);
delete m_runner; delete m_runner;
m_runner = 0; m_runner = nullptr;
m_logMessages.clear(); m_logMessages.clear();
m_errors.clear(); m_errors.clear();

View File

@@ -42,7 +42,7 @@ class ValgrindTestRunnerTest : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit ValgrindTestRunnerTest(QObject *parent = 0); explicit ValgrindTestRunnerTest(QObject *parent = nullptr);
private slots: private slots:
void init(); void init();

View File

@@ -38,12 +38,7 @@ namespace XmlProtocol {
class AnnounceThread::Private : public QSharedData class AnnounceThread::Private : public QSharedData
{ {
public: public:
Private() qint64 hThreadId = -1;
: hThreadId( -1 )
{
}
qint64 hThreadId;
QVector<Frame> stack; QVector<Frame> stack;
}; };
@@ -52,14 +47,9 @@ AnnounceThread::AnnounceThread()
{ {
} }
AnnounceThread::AnnounceThread(const AnnounceThread &other) AnnounceThread::AnnounceThread(const AnnounceThread &other) = default;
: d(other.d)
{
}
AnnounceThread::~AnnounceThread() AnnounceThread::~AnnounceThread() = default;
{
}
void AnnounceThread::swap(AnnounceThread &other) void AnnounceThread::swap(AnnounceThread &other)
{ {

View File

@@ -42,24 +42,15 @@ namespace XmlProtocol {
class Error::Private : public QSharedData class Error::Private : public QSharedData
{ {
public: public:
explicit Private() : qint64 unique = 0;
unique(0), qint64 tid = 0;
tid(0),
kind(0),
leakedBytes(0),
leakedBlocks(0),
hThreadId(-1)
{}
qint64 unique;
qint64 tid;
QString what; QString what;
int kind; int kind = 0;
QVector<Stack> stacks; QVector<Stack> stacks;
Suppression suppression; Suppression suppression;
quint64 leakedBytes; quint64 leakedBytes = 0;
qint64 leakedBlocks; qint64 leakedBlocks = 0;
qint64 hThreadId; qint64 hThreadId = -1;
bool operator==(const Private &other) const bool operator==(const Private &other) const
{ {
@@ -80,14 +71,9 @@ Error::Error() :
{ {
} }
Error::~Error() Error::~Error() = default;
{
}
Error::Error(const Error &other) : Error::Error(const Error &other) = default;
d( other.d )
{
}
void Error::swap(Error &other) void Error::swap(Error &other)
{ {

View File

@@ -288,7 +288,7 @@ QVariant FrameItem::data(int column, int role) const
const ErrorItem *FrameItem::getErrorItem() const const ErrorItem *FrameItem::getErrorItem() const
{ {
for (const TreeItem *parentItem = parent(); parentItem; parentItem = parentItem->parent()) { for (const TreeItem *parentItem = parent(); parentItem; parentItem = parentItem->parent()) {
const ErrorItem * const errorItem = dynamic_cast<const ErrorItem *>(parentItem); auto const errorItem = dynamic_cast<const ErrorItem *>(parentItem);
if (errorItem) if (errorItem)
return errorItem; return errorItem;
} }

View File

@@ -46,9 +46,9 @@ public:
ErrorRole = Debugger::DetailedErrorView::FullTextRole + 1, ErrorRole = Debugger::DetailedErrorView::FullTextRole + 1,
}; };
explicit ErrorListModel(QObject *parent = 0); explicit ErrorListModel(QObject *parent = nullptr);
typedef std::function<Frame(const Error &)> RelevantFrameFinder; using RelevantFrameFinder = std::function<Frame (const Error &)>;
RelevantFrameFinder relevantFrameFinder() const; RelevantFrameFinder relevantFrameFinder() const;
void setRelevantFrameFinder(const RelevantFrameFinder &relevantFrameFinder); void setRelevantFrameFinder(const RelevantFrameFinder &relevantFrameFinder);

View File

@@ -36,8 +36,6 @@ namespace XmlProtocol {
class Frame::Private : public QSharedData class Frame::Private : public QSharedData
{ {
public: public:
Private() : ip(0), line(-1) {}
bool operator==(const Private &other) const bool operator==(const Private &other) const
{ {
return ip == other.ip return ip == other.ip
@@ -48,26 +46,21 @@ public:
&& line == other.line; && line == other.line;
} }
quint64 ip; quint64 ip = 0;
QString object; QString object;
QString functionName; QString functionName;
QString fileName; QString fileName;
QString directory; QString directory;
int line; int line = -1;
}; };
Frame::Frame() : d(new Private) Frame::Frame() : d(new Private)
{ {
} }
Frame::~Frame() Frame::~Frame() = default;
{
}
Frame::Frame(const Frame &other) : Frame::Frame(const Frame &other) = default;
d(other.d)
{
}
Frame &Frame::operator=(const Frame &other) Frame &Frame::operator=(const Frame &other)
{ {

View File

@@ -44,7 +44,7 @@ QString toolTipForFrame(const Frame &frame)
location += ':' + QString::number(frame.line()); location += ':' + QString::number(frame.line());
} }
typedef QPair<QString, QString> StringPair; using StringPair = QPair<QString, QString>;
QList<StringPair> lines; QList<StringPair> lines;
if (!frame.functionName().isEmpty()) if (!frame.functionName().isEmpty())

View File

@@ -50,7 +50,7 @@ namespace {
: m_message(message) : m_message(message)
{} {}
~ParserException() throw() {} ~ParserException() noexcept = default;
QString message() const { return m_message; } QString message() const { return m_message; }
@@ -60,23 +60,21 @@ namespace {
struct XWhat struct XWhat
{ {
XWhat() : leakedblocks(0), leakedbytes(0), hthreadid(-1) {}
QString text; QString text;
qint64 leakedblocks; qint64 leakedblocks = 0;
qint64 leakedbytes; qint64 leakedbytes = 0;
qint64 hthreadid; qint64 hthreadid = -1;
}; };
struct XauxWhat struct XauxWhat
{ {
XauxWhat() : line(-1), hthreadid(-1) {}
void clear() { *this = XauxWhat(); } void clear() { *this = XauxWhat(); }
QString text; QString text;
QString file; QString file;
QString dir; QString dir;
qint64 line; qint64 line = -1;
qint64 hthreadid; qint64 hthreadid = -1;
}; };
} // namespace anon } // namespace anon
@@ -215,7 +213,7 @@ QXmlStreamReader::TokenType Parser::Private::blockingReadNext()
// ...so we fall back to knowing it might be a QAbstractSocket. // ...so we fall back to knowing it might be a QAbstractSocket.
QIODevice *dev = reader.device(); QIODevice *dev = reader.device();
QAbstractSocket *sock = qobject_cast<QAbstractSocket *>(dev); auto sock = qobject_cast<const QAbstractSocket *>(dev);
if (!sock || sock->state() != QAbstractSocket::ConnectedState) if (!sock || sock->state() != QAbstractSocket::ConnectedState)
throw ParserException(dev->errorString()); throw ParserException(dev->errorString());

View File

@@ -54,8 +54,8 @@ public:
Helgrind Helgrind
}; };
explicit Parser(QObject *parent=0); explicit Parser(QObject *parent = nullptr);
~Parser(); ~Parser() override;
QString errorString() const; QString errorString() const;
void parse(QIODevice *stream); void parse(QIODevice *stream);

View File

@@ -37,17 +37,11 @@ namespace XmlProtocol {
class Stack::Private : public QSharedData class Stack::Private : public QSharedData
{ {
public: public:
Private()
: line(-1)
, hthreadid(-1)
{
}
QString auxwhat; QString auxwhat;
QString file; QString file;
QString dir; QString dir;
qint64 line; qint64 line = -1;
qint64 hthreadid; qint64 hthreadid = -1;
QVector<Frame> frames; QVector<Frame> frames;
}; };
@@ -56,14 +50,9 @@ Stack::Stack()
{ {
} }
Stack::Stack(const Stack &other) Stack::Stack(const Stack &other) = default;
: d(other.d)
{
}
Stack::~Stack() Stack::~Stack() = default;
{
}
void Stack::swap(Stack &other) void Stack::swap(Stack &other)
{ {

View File

@@ -56,15 +56,15 @@ public:
LineRole LineRole
}; };
explicit StackModel(QObject *parent = 0); explicit StackModel(QObject *parent = nullptr);
~StackModel(); ~StackModel() override;
QVariant data(const QModelIndex &index, int role) const; QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &child) const; QModelIndex parent(const QModelIndex &child) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const override;
void clear(); void clear();
void setError(const Valgrind::XmlProtocol::Error &error); void setError(const Valgrind::XmlProtocol::Error &error);

View File

@@ -35,12 +35,7 @@ namespace XmlProtocol {
class Status::Private : public QSharedData class Status::Private : public QSharedData
{ {
public: public:
Private() State state = Running;
: state(Running)
{
}
State state;
QString time; QString time;
}; };
@@ -49,14 +44,9 @@ Status::Status()
{ {
} }
Status::Status(const Status &other) Status::Status(const Status &other) = default;
: d(other.d)
{
}
Status::~Status() Status::~Status() = default;
{
}
void Status::swap(Status &other) void Status::swap(Status &other)
{ {

View File

@@ -39,10 +39,6 @@ using namespace Valgrind::XmlProtocol;
class SuppressionFrame::Private : public QSharedData class SuppressionFrame::Private : public QSharedData
{ {
public: public:
Private()
{
}
QString obj; QString obj;
QString fun; QString fun;
}; };
@@ -52,14 +48,9 @@ SuppressionFrame::SuppressionFrame()
{ {
} }
SuppressionFrame::SuppressionFrame(const SuppressionFrame &other) SuppressionFrame::SuppressionFrame(const SuppressionFrame &other) = default;
: d(other.d)
{
}
SuppressionFrame::~SuppressionFrame() SuppressionFrame::~SuppressionFrame() = default;
{
}
void SuppressionFrame::swap(SuppressionFrame &other) void SuppressionFrame::swap(SuppressionFrame &other)
{ {
@@ -110,12 +101,7 @@ QString SuppressionFrame::toString() const
class Suppression::Private : public QSharedData class Suppression::Private : public QSharedData
{ {
public: public:
Private() bool isNull = true;
: isNull(true)
{
}
bool isNull;
QString name; QString name;
QString kind; QString kind;
QString auxkind; QString auxkind;
@@ -128,14 +114,9 @@ Suppression::Suppression()
{ {
} }
Suppression::Suppression(const Suppression &other) Suppression::Suppression(const Suppression &other) = default;
: d(other.d)
{
}
Suppression::~Suppression() Suppression::~Suppression() = default;
{
}
void Suppression::swap(Suppression &other) void Suppression::swap(Suppression &other)
{ {

View File

@@ -63,7 +63,7 @@ private:
QSharedDataPointer<Private> d; QSharedDataPointer<Private> d;
}; };
typedef QVector<SuppressionFrame> SuppressionFrames; using SuppressionFrames = QVector<SuppressionFrame>;
class Suppression class Suppression
{ {

View File

@@ -42,20 +42,18 @@ namespace {
class Thread : public QThread class Thread : public QThread
{ {
public: public:
Thread() : parser(0) , device(0) {} void run() override
void run()
{ {
QTC_ASSERT(QThread::currentThread() == this, return); QTC_ASSERT(QThread::currentThread() == this, return);
parser->parse(device); parser->parse(device);
delete parser; delete parser;
parser = 0; parser = nullptr;
delete device; delete device;
device = 0; device = nullptr;
} }
Valgrind::XmlProtocol::Parser *parser; Valgrind::XmlProtocol::Parser *parser = nullptr;
QIODevice *device; QIODevice *device = nullptr;
}; };
} // namespace anon } // namespace anon
@@ -67,9 +65,6 @@ namespace XmlProtocol {
class ThreadedParser::Private class ThreadedParser::Private
{ {
public: public:
Private()
{}
QPointer<Thread> parserThread; QPointer<Thread> parserThread;
QString errorString; QString errorString;
}; };
@@ -93,14 +88,14 @@ QString ThreadedParser::errorString() const
bool ThreadedParser::isRunning() const bool ThreadedParser::isRunning() const
{ {
return d->parserThread ? d->parserThread.data()->isRunning() : 0; return d->parserThread ? d->parserThread.data()->isRunning() : false;
} }
void ThreadedParser::parse(QIODevice *device) void ThreadedParser::parse(QIODevice *device)
{ {
QTC_ASSERT(!d->parserThread, return); QTC_ASSERT(!d->parserThread, return);
Parser *parser = new Parser; auto parser = new Parser;
qRegisterMetaType<Valgrind::XmlProtocol::Status>(); qRegisterMetaType<Valgrind::XmlProtocol::Status>();
qRegisterMetaType<Valgrind::XmlProtocol::Error>(); qRegisterMetaType<Valgrind::XmlProtocol::Error>();
connect(parser, &Parser::status, connect(parser, &Parser::status,
@@ -123,11 +118,11 @@ void ThreadedParser::parse(QIODevice *device)
Qt::QueuedConnection); Qt::QueuedConnection);
Thread *thread = new Thread; auto thread = new Thread;
d->parserThread = thread; d->parserThread = thread;
connect(thread, &QThread::finished, connect(thread, &QThread::finished,
thread, &QObject::deleteLater); thread, &QObject::deleteLater);
device->setParent(0); device->setParent(nullptr);
device->moveToThread(thread); device->moveToThread(thread);
parser->moveToThread(thread); parser->moveToThread(thread);
thread->device = device; thread->device = device;

View File

@@ -46,8 +46,8 @@ class ThreadedParser : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit ThreadedParser(QObject *parent = 0); explicit ThreadedParser(QObject *parent = nullptr);
~ThreadedParser(); ~ThreadedParser() override;
QString errorString() const; QString errorString() const;