Debugger: Modernize

modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init
modernize-use-equals-default

Change-Id: I91a6874f0d7b94e9079ab4ef07c23c60c80be9c0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Alessandro Portale
2018-07-23 22:28:49 +02:00
parent babf038ce8
commit 0558db7b54
104 changed files with 718 additions and 820 deletions

View File

@@ -127,7 +127,7 @@ struct QmlV8ObjectData
}
};
typedef std::function<void(const QVariantMap &)> QmlCallback;
using QmlCallback = std::function<void(const QVariantMap &)>;
struct LookupData
{
@@ -136,7 +136,7 @@ struct LookupData
QString exp;
};
typedef QHash<int, LookupData> LookupItems; // id -> (iname, exp)
using LookupItems = QHash<int, LookupData>; // id -> (iname, exp)
static void setWatchItemHasChildren(WatchItem *item, bool hasChildren)
{
@@ -415,7 +415,7 @@ void QmlEngine::connectionStartupFailed()
return;
}
QMessageBox *infoBox = new QMessageBox(ICore::mainWindow());
auto infoBox = new QMessageBox(ICore::mainWindow());
infoBox->setIcon(QMessageBox::Critical);
infoBox->setWindowTitle(Core::Constants::IDE_DISPLAY_NAME);
infoBox->setText(tr("Could not connect to the in-process QML debugger."
@@ -436,7 +436,7 @@ void QmlEngine::appStartupFailed(const QString &errorMessage)
QString error = tr("Could not connect to the in-process QML debugger. %1").arg(errorMessage);
if (isMasterEngine()) {
QMessageBox *infoBox = new QMessageBox(ICore::mainWindow());
auto infoBox = new QMessageBox(ICore::mainWindow());
infoBox->setIcon(QMessageBox::Critical);
infoBox->setWindowTitle(Core::Constants::IDE_DISPLAY_NAME);
infoBox->setText(error);
@@ -935,9 +935,9 @@ void QmlEngine::selectWatchData(const QString &iname)
bool compareConsoleItems(const ConsoleItem *a, const ConsoleItem *b)
{
if (a == 0)
if (a == nullptr)
return true;
if (b == 0)
if (b == nullptr)
return false;
return a->text() < b->text();
}
@@ -947,7 +947,7 @@ static ConsoleItem *constructLogItemTree(const QVariant &result,
{
bool sorted = boolSetting(SortStructMembers);
if (!result.isValid())
return 0;
return nullptr;
QString text;
ConsoleItem *item = nullptr;

View File

@@ -58,7 +58,7 @@ public:
Node::accept(ast, this);
}
bool preVisit(Node *ast)
bool preVisit(Node *ast) override
{
return !done && ast->lastSourceLocation().startLine >= *line;
}
@@ -73,7 +73,7 @@ public:
//Add more types when suitable.
bool visit(UiScriptBinding *ast)
bool visit(UiScriptBinding *ast) override
{
if (!ast->statement)
return true;
@@ -87,7 +87,7 @@ public:
statementColumn = ast->statement->firstSourceLocation().startColumn;
} else if (ast->statement->kind == Node::Kind_Block) {
Block *block = static_cast<Block *>(ast->statement);
auto block = static_cast<Block *>(ast->statement);
if (!block->statements)
return true;
statementStartLine = block->statements->firstSourceLocation().startLine;
@@ -124,7 +124,7 @@ public:
return true;
}
bool visit(FunctionDeclaration *ast) {
bool visit(FunctionDeclaration *ast) override {
quint32 sourceStartLine = ast->firstSourceLocation().startLine;
quint32 sourceStartColumn = ast->firstSourceLocation().startColumn;
quint32 statementStartLine = ast->body->firstSourceLocation().startLine;
@@ -152,39 +152,39 @@ public:
return true;
}
bool visit(EmptyStatement *ast)
bool visit(EmptyStatement *ast) override
{
*line = ast->lastSourceLocation().startLine + 1;
return true;
}
bool visit(VariableStatement *ast) { test(ast); return true; }
bool visit(VariableDeclarationList *ast) { test(ast); return true; }
bool visit(VariableDeclaration *ast) { test(ast); return true; }
bool visit(ExpressionStatement *ast) { test(ast); return true; }
bool visit(IfStatement *ast) { test(ast); return true; }
bool visit(DoWhileStatement *ast) { test(ast); return true; }
bool visit(WhileStatement *ast) { test(ast); return true; }
bool visit(ForStatement *ast) { test(ast); return true; }
bool visit(LocalForStatement *ast) { test(ast); return true; }
bool visit(ForEachStatement *ast) { test(ast); return true; }
bool visit(LocalForEachStatement *ast) { test(ast); return true; }
bool visit(ContinueStatement *ast) { test(ast); return true; }
bool visit(BreakStatement *ast) { test(ast); return true; }
bool visit(ReturnStatement *ast) { test(ast); return true; }
bool visit(WithStatement *ast) { test(ast); return true; }
bool visit(SwitchStatement *ast) { test(ast); return true; }
bool visit(CaseBlock *ast) { test(ast); return true; }
bool visit(CaseClauses *ast) { test(ast); return true; }
bool visit(CaseClause *ast) { test(ast); return true; }
bool visit(DefaultClause *ast) { test(ast); return true; }
bool visit(LabelledStatement *ast) { test(ast); return true; }
bool visit(ThrowStatement *ast) { test(ast); return true; }
bool visit(TryStatement *ast) { test(ast); return true; }
bool visit(Catch *ast) { test(ast); return true; }
bool visit(Finally *ast) { test(ast); return true; }
bool visit(FunctionExpression *ast) { test(ast); return true; }
bool visit(DebuggerStatement *ast) { test(ast); return true; }
bool visit(VariableStatement *ast) override { test(ast); return true; }
bool visit(VariableDeclarationList *ast) override { test(ast); return true; }
bool visit(VariableDeclaration *ast) override { test(ast); return true; }
bool visit(ExpressionStatement *ast) override { test(ast); return true; }
bool visit(IfStatement *ast) override { test(ast); return true; }
bool visit(DoWhileStatement *ast) override { test(ast); return true; }
bool visit(WhileStatement *ast) override { test(ast); return true; }
bool visit(ForStatement *ast) override { test(ast); return true; }
bool visit(LocalForStatement *ast) override { test(ast); return true; }
bool visit(ForEachStatement *ast) override { test(ast); return true; }
bool visit(LocalForEachStatement *ast) override { test(ast); return true; }
bool visit(ContinueStatement *ast) override { test(ast); return true; }
bool visit(BreakStatement *ast) override { test(ast); return true; }
bool visit(ReturnStatement *ast) override { test(ast); return true; }
bool visit(WithStatement *ast) override { test(ast); return true; }
bool visit(SwitchStatement *ast) override { test(ast); return true; }
bool visit(CaseBlock *ast) override { test(ast); return true; }
bool visit(CaseClauses *ast) override { test(ast); return true; }
bool visit(CaseClause *ast) override { test(ast); return true; }
bool visit(DefaultClause *ast) override { test(ast); return true; }
bool visit(LabelledStatement *ast) override { test(ast); return true; }
bool visit(ThrowStatement *ast) override { test(ast); return true; }
bool visit(TryStatement *ast) override { test(ast); return true; }
bool visit(Catch *ast) override { test(ast); return true; }
bool visit(Finally *ast) override { test(ast); return true; }
bool visit(FunctionExpression *ast) override { test(ast); return true; }
bool visit(DebuggerStatement *ast) override { test(ast); return true; }
void test(Node *ast)
{
@@ -247,7 +247,7 @@ QStringList highlightExceptionCode(int lineNumber, const QString &filePath, cons
QTextCharFormat errorFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR);
for (IEditor *editor : editors) {
TextEditorWidget *ed = qobject_cast<TextEditorWidget *>(editor->widget());
auto ed = qobject_cast<TextEditorWidget *>(editor->widget());
if (!ed)
continue;

View File

@@ -66,21 +66,14 @@ Q_LOGGING_CATEGORY(qmlInspectorLog, "qtc.dbg.qmlinspector")
*/
QmlInspectorAgent::QmlInspectorAgent(QmlEngine *engine, QmlDebugConnection *connection)
: m_qmlEngine(engine)
, m_engineClient(0)
, m_engineQueryId(0)
, m_rootContextQueryId(0)
, m_objectToSelect(WatchItem::InvalidId)
, m_masterEngine(engine->masterEngine())
, m_toolsClient(0)
, m_targetToSync(NoTarget)
, m_debugIdToSelect(WatchItem::InvalidId)
, m_currentSelectedDebugId(WatchItem::InvalidId)
, m_toolsClientConnected(false)
, m_inspectorToolsContext("Debugger.QmlInspector")
, m_selectAction(new QAction(this))
, m_zoomAction(new QAction(this))
, m_showAppOnTopAction(action(ShowAppOnTop))
, m_engineClientConnected(false)
{
m_debugIdToIname.insert(WatchItem::InvalidId, "inspect");
connect(action(ShowQmlObjectTree),
@@ -396,7 +389,7 @@ static bool insertChildren(WatchItem *parent, const QVariant &value)
case QVariant::Map: {
const QVariantMap map = value.toMap();
for (auto it = map.begin(), end = map.end(); it != end; ++it) {
WatchItem *child = new WatchItem;
auto child = new WatchItem;
child->name = it.key();
child->value = it.value().toString();
child->type = QLatin1String(it.value().typeName());
@@ -410,7 +403,7 @@ static bool insertChildren(WatchItem *parent, const QVariant &value)
case QVariant::List: {
const QVariantList list = value.toList();
for (int i = 0, end = list.size(); i != end; ++i) {
WatchItem *child = new WatchItem;
auto child = new WatchItem;
const QVariant &value = list.at(i);
child->arrayIndex = i;
child->value = value.toString();
@@ -756,7 +749,7 @@ void QmlInspectorAgent::clientStateChanged(QmlDebugClient::State state)
{
QString serviceName;
float version = 0;
if (QmlDebugClient *client = qobject_cast<QmlDebugClient*>(sender())) {
if (auto client = qobject_cast<QmlDebugClient*>(sender())) {
serviceName = client->name();
version = client->serviceVersion();
}
@@ -766,7 +759,7 @@ void QmlInspectorAgent::clientStateChanged(QmlDebugClient::State state)
void QmlInspectorAgent::toolsClientStateChanged(QmlDebugClient::State state)
{
BaseToolsClient *client = qobject_cast<BaseToolsClient*>(sender());
auto client = qobject_cast<BaseToolsClient*>(sender());
QTC_ASSERT(client, return);
if (state == QmlDebugClient::Enabled) {
m_toolsClient = client;
@@ -820,8 +813,7 @@ void QmlInspectorAgent::toolsClientStateChanged(QmlDebugClient::State state)
void QmlInspectorAgent::engineClientStateChanged(QmlDebugClient::State state)
{
BaseEngineDebugClient *client
= qobject_cast<BaseEngineDebugClient*>(sender());
auto client = qobject_cast<BaseEngineDebugClient*>(sender());
if (state == QmlDebugClient::Enabled && !m_engineClientConnected) {
// We accept the first client that is enabled and reject the others.

View File

@@ -49,8 +49,8 @@ class QmlEngine;
class WatchItem;
//map <filename, editorRevision> -> <lineNumber, columnNumber> -> debugId
typedef
QHash<QPair<QString, int>, QHash<QPair<int, int>, QList<int> > > DebugIdHash;
using DebugIdHash =
QHash<QPair<QString, int>, QHash<QPair<int, int>, QList<int> > >;
class QmlInspectorAgent : public QObject
{
@@ -118,10 +118,10 @@ private:
private:
QPointer<QmlEngine> m_qmlEngine;
QmlDebug::BaseEngineDebugClient *m_engineClient;
QmlDebug::BaseEngineDebugClient *m_engineClient = nullptr;
quint32 m_engineQueryId;
quint32 m_rootContextQueryId;
quint32 m_engineQueryId = 0;
quint32 m_rootContextQueryId = 0;
int m_objectToSelect;
QList<quint32> m_objectTreeQueryIds;
QStack<QmlDebug::ObjectReference> m_objectStack;
@@ -136,22 +136,22 @@ private:
DebuggerEngine *m_masterEngine;
QHash<QString, QmlDebug::BaseEngineDebugClient*> m_engineClients;
QmlDebug::BaseToolsClient *m_toolsClient;
QmlDebug::BaseToolsClient *m_toolsClient = nullptr;
SelectionTarget m_targetToSync;
SelectionTarget m_targetToSync = NoTarget;
int m_debugIdToSelect;
int m_currentSelectedDebugId;
QString m_currentSelectedDebugName;
// toolbar
bool m_toolsClientConnected;
bool m_toolsClientConnected = false;
Core::Context m_inspectorToolsContext;
QAction *m_selectAction;
QAction *m_zoomAction;
QAction *m_showAppOnTopAction;
bool m_engineClientConnected;
bool m_engineClientConnected = false;
};
} // Internal