From f6943a712abd5cf1f213aeb5cb984a4ab61ae139 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 23 Jul 2018 10:45:40 +0200 Subject: [PATCH] Utils: Modernize further Many issues, mostly in headers, were not addressed in e38410b76c40ffde33cf1ab405926cd243c4e48c modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using modernize-use-default-member-init modernize-use-equals-default Change-Id: I320a51726db881e582b898948d53735ebb06887a Reviewed-by: hjk --- src/libs/utils/algorithm.h | 4 ++-- src/libs/utils/ansiescapecodehandler.h | 4 ++-- src/libs/utils/appmainwindow.h | 2 +- src/libs/utils/basetreeview.h | 2 +- src/libs/utils/changeset.h | 21 +++++++++---------- src/libs/utils/consoleprocess_p.h | 28 +++++++++++++------------- src/libs/utils/consoleprocess_unix.cpp | 13 +----------- src/libs/utils/consoleprocess_win.cpp | 14 +------------ src/libs/utils/delegates.cpp | 5 ++--- src/libs/utils/delegates.h | 2 +- src/libs/utils/dropsupport.h | 2 +- src/libs/utils/elfreader.h | 4 ++-- src/libs/utils/environment.h | 2 +- src/libs/utils/fancylineedit.h | 2 +- src/libs/utils/filesearch.h | 28 +++++++++++++------------- src/libs/utils/fileutils.cpp | 6 +----- src/libs/utils/fileutils.h | 4 ++-- src/libs/utils/fixedsizeclicklabel.cpp | 1 - src/libs/utils/fixedsizeclicklabel.h | 2 +- src/libs/utils/htmldocextractor.cpp | 5 +---- src/libs/utils/htmldocextractor.h | 4 ++-- src/libs/utils/icon.h | 2 +- src/libs/utils/json.h | 2 +- src/libs/utils/link.h | 8 +++----- src/libs/utils/macroexpander.h | 12 +++++------ src/libs/utils/overridecursor.cpp | 2 +- src/libs/utils/overridecursor.h | 2 +- src/libs/utils/port.h | 4 ++-- src/libs/utils/proxyaction.cpp | 6 +----- src/libs/utils/proxyaction.h | 8 ++++---- src/libs/utils/qtcprocess.cpp | 4 +--- src/libs/utils/qtcprocess.h | 9 +++++---- src/libs/utils/savedaction.cpp | 1 - src/libs/utils/savedaction.h | 6 +++--- src/libs/utils/savefile.cpp | 2 +- src/libs/utils/savefile.h | 2 +- src/libs/utils/scopedswap.h | 2 +- src/libs/utils/settingsaccessor.h | 4 ++-- src/libs/utils/settingsselector.h | 4 ++-- src/libs/utils/shellcommand.cpp | 1 - src/libs/utils/shellcommand.h | 2 +- src/libs/utils/statuslabel.cpp | 2 +- src/libs/utils/statuslabel.h | 2 +- src/libs/utils/synchronousprocess.cpp | 4 ++-- src/libs/utils/textfileformat.cpp | 5 +---- src/libs/utils/textfileformat.h | 6 +++--- src/libs/utils/treemodel.cpp | 5 +---- src/libs/utils/treemodel.h | 4 ++-- src/libs/utils/treeviewcombobox.cpp | 2 +- src/libs/utils/treeviewcombobox.h | 2 +- src/libs/utils/uncommentselection.cpp | 7 ++----- src/libs/utils/uncommentselection.h | 2 +- src/libs/utils/wizard.cpp | 11 +++------- 53 files changed, 117 insertions(+), 173 deletions(-) diff --git a/src/libs/utils/algorithm.h b/src/libs/utils/algorithm.h index 4a0d18e945a..42dd638fbfc 100644 --- a/src/libs/utils/algorithm.h +++ b/src/libs/utils/algorithm.h @@ -229,7 +229,7 @@ protected: Container *container; public: - typedef Container container_type; + using container_type = Container; explicit SetInsertIterator (Container &x) : container(&x) {} SetInsertIterator &operator=(const typename Container::value_type &value) @@ -253,7 +253,7 @@ template Container *container; public: - typedef Container container_type; + using container_type = Container; explicit MapInsertIterator (Container &x) : container(&x) {} MapInsertIterator &operator=(const std::pair &value) diff --git a/src/libs/utils/ansiescapecodehandler.h b/src/libs/utils/ansiescapecodehandler.h index 04512976211..b2e848f8458 100644 --- a/src/libs/utils/ansiescapecodehandler.h +++ b/src/libs/utils/ansiescapecodehandler.h @@ -33,8 +33,8 @@ namespace Utils { class QTCREATOR_UTILS_EXPORT FormattedText { public: - FormattedText() { } - FormattedText(const FormattedText &other) : text(other.text), format(other.format) { } + FormattedText() = default; + FormattedText(const FormattedText &other) = default; FormattedText(const QString &txt, const QTextCharFormat &fmt = QTextCharFormat()) : text(txt), format(fmt) { } diff --git a/src/libs/utils/appmainwindow.h b/src/libs/utils/appmainwindow.h index c93695550db..916772a5d12 100644 --- a/src/libs/utils/appmainwindow.h +++ b/src/libs/utils/appmainwindow.h @@ -45,7 +45,7 @@ signals: #ifdef Q_OS_WIN protected: virtual bool winEvent(MSG *message, long *result); - virtual bool event(QEvent *event); + bool event(QEvent *event) override; #endif private: diff --git a/src/libs/utils/basetreeview.h b/src/libs/utils/basetreeview.h index 653d9fb22b0..923c69b0421 100644 --- a/src/libs/utils/basetreeview.h +++ b/src/libs/utils/basetreeview.h @@ -110,7 +110,7 @@ template T *checkEventType(QEvent *ev) class QTCREATOR_UTILS_EXPORT ItemViewEvent { public: - ItemViewEvent() {} + ItemViewEvent() = default; ItemViewEvent(QEvent *ev, QAbstractItemView *view); template T *as() const { diff --git a/src/libs/utils/changeset.h b/src/libs/utils/changeset.h index d445237b44f..4b63cfb7274 100644 --- a/src/libs/utils/changeset.h +++ b/src/libs/utils/changeset.h @@ -49,26 +49,25 @@ public: Copy }; - EditOp(): type(Unset), pos1(0), pos2(0), length1(0), length2(0) {} - EditOp(Type t): type(t), pos1(0), pos2(0), length1(0), length2(0) {} + EditOp() = default; + EditOp(Type t): type(t) {} - Type type; - int pos1; - int pos2; - int length1; - int length2; + Type type = Unset; + int pos1 = 0; + int pos2 = 0; + int length1 = 0; + int length2 = 0; QString text; }; struct Range { - Range() - : start(0), end(0) {} + Range() = default; Range(int start, int end) : start(start), end(end) {} - int start; - int end; + int start = 0; + int end = 0; }; public: diff --git a/src/libs/utils/consoleprocess_p.h b/src/libs/utils/consoleprocess_p.h index 8fa610a7093..5d8d1934934 100644 --- a/src/libs/utils/consoleprocess_p.h +++ b/src/libs/utils/consoleprocess_p.h @@ -48,32 +48,32 @@ struct ConsoleProcessPrivate { ConsoleProcessPrivate(); static QString m_defaultConsoleProcess; - ConsoleProcess::Mode m_mode; + ConsoleProcess::Mode m_mode = ConsoleProcess::Run; QString m_workingDir; Environment m_environment; - qint64 m_appPid; + qint64 m_appPid = 0; int m_appCode; QString m_executable; QProcess::ExitStatus m_appStatus; QLocalServer m_stubServer; - QLocalSocket *m_stubSocket; - QTemporaryFile *m_tempFile; - QProcess::ProcessError m_error; + QLocalSocket *m_stubSocket = nullptr; + QTemporaryFile *m_tempFile = nullptr; + QProcess::ProcessError m_error = QProcess::UnknownError; QString m_errorString; #ifdef Q_OS_UNIX QProcess m_process; QByteArray m_stubServerDir; - QSettings *m_settings; - bool m_stubConnected; - qint64 m_stubPid; - QTimer *m_stubConnectTimer; + QSettings *m_settings = nullptr; + bool m_stubConnected = false; + qint64 m_stubPid = 0; + QTimer *m_stubConnectTimer = nullptr; #else - qint64 m_appMainThreadId; - PROCESS_INFORMATION *m_pid; - HANDLE m_hInferior; - QWinEventNotifier *inferiorFinishedNotifier; - QWinEventNotifier *processFinishedNotifier; + qint64 m_appMainThreadId = 0; + PROCESS_INFORMATION *m_pid = nullptr; + HANDLE m_hInferior = NULL; + QWinEventNotifier *inferiorFinishedNotifier = nullptr; + QWinEventNotifier *processFinishedNotifier = nullptr; #endif }; diff --git a/src/libs/utils/consoleprocess_unix.cpp b/src/libs/utils/consoleprocess_unix.cpp index 223f8ebdab8..be07027f6e3 100644 --- a/src/libs/utils/consoleprocess_unix.cpp +++ b/src/libs/utils/consoleprocess_unix.cpp @@ -43,18 +43,7 @@ namespace Utils { -ConsoleProcessPrivate::ConsoleProcessPrivate() : - m_mode(ConsoleProcess::Run), - m_appPid(0), - m_stubSocket(0), - m_tempFile(0), - m_error(QProcess::UnknownError), - m_settings(0), - m_stubConnected(false), - m_stubPid(0), - m_stubConnectTimer(0) -{ -} +ConsoleProcessPrivate::ConsoleProcessPrivate() = default; ConsoleProcess::ConsoleProcess(QObject *parent) : QObject(parent), d(new ConsoleProcessPrivate) diff --git a/src/libs/utils/consoleprocess_win.cpp b/src/libs/utils/consoleprocess_win.cpp index 27ef6cc4d7b..344642542ea 100644 --- a/src/libs/utils/consoleprocess_win.cpp +++ b/src/libs/utils/consoleprocess_win.cpp @@ -36,19 +36,7 @@ namespace Utils { -ConsoleProcessPrivate::ConsoleProcessPrivate() : - m_mode(ConsoleProcess::Run), - m_appPid(0), - m_stubSocket(nullptr), - m_tempFile(nullptr), - m_error(QProcess::UnknownError), - m_appMainThreadId(0), - m_pid(nullptr), - m_hInferior(NULL), - inferiorFinishedNotifier(nullptr), - processFinishedNotifier(nullptr) -{ -} +ConsoleProcessPrivate::ConsoleProcessPrivate() = default; ConsoleProcess::ConsoleProcess(QObject *parent) : QObject(parent), d(new ConsoleProcessPrivate) diff --git a/src/libs/utils/delegates.cpp b/src/libs/utils/delegates.cpp index bbc1a422654..6b6ab7279ef 100644 --- a/src/libs/utils/delegates.cpp +++ b/src/libs/utils/delegates.cpp @@ -114,7 +114,6 @@ QSize AnnotatedItemDelegate::sizeHint(const QStyleOptionViewItem &option, PathChooserDelegate::PathChooserDelegate(QObject *parent) : QStyledItemDelegate(parent) - , m_kind(Utils::PathChooser::ExistingDirectory) { } @@ -133,7 +132,7 @@ QWidget *PathChooserDelegate::createEditor(QWidget *parent, const QStyleOptionVi Q_UNUSED(option); Q_UNUSED(index); - Utils::PathChooser *editor = new Utils::PathChooser(parent); + auto editor = new Utils::PathChooser(parent); editor->setHistoryCompleter(m_historyKey); editor->setAutoFillBackground(true); // To hide the text beneath the editor widget @@ -157,7 +156,7 @@ void PathChooserDelegate::setEditorData(QWidget *editor, const QModelIndex &inde void PathChooserDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { - Utils::PathChooser *pathChooser = qobject_cast(editor); + auto pathChooser = qobject_cast(editor); if (!pathChooser) return; diff --git a/src/libs/utils/delegates.h b/src/libs/utils/delegates.h index 7deab7a3729..cb9809a36f4 100644 --- a/src/libs/utils/delegates.h +++ b/src/libs/utils/delegates.h @@ -76,7 +76,7 @@ public: void setHistoryCompleter(const QString &key); private: - PathChooser::Kind m_kind; + PathChooser::Kind m_kind = PathChooser::ExistingDirectory; QString m_filter; QString m_historyKey; }; diff --git a/src/libs/utils/dropsupport.h b/src/libs/utils/dropsupport.h index a423a360464..daff8f7537b 100644 --- a/src/libs/utils/dropsupport.h +++ b/src/libs/utils/dropsupport.h @@ -51,7 +51,7 @@ public: int column; }; // returns true if the event should be accepted - typedef std::function DropFilterFunction; + using DropFilterFunction = std::function; DropSupport(QWidget *parentWidget, const DropFilterFunction &filterFunction = DropFilterFunction()); diff --git a/src/libs/utils/elfreader.h b/src/libs/utils/elfreader.h index d1c1dc22862..cc82e71d018 100644 --- a/src/libs/utils/elfreader.h +++ b/src/libs/utils/elfreader.h @@ -137,7 +137,7 @@ public: class QTCREATOR_UTILS_EXPORT ElfData { public: - ElfData() : symbolsType(UnknownSymbols) {} + ElfData() = default; int indexOf(const QByteArray &name) const; public: @@ -148,7 +148,7 @@ public: quint64 entryPoint; QByteArray debugLink; QByteArray buildId; - DebugSymbolsType symbolsType; + DebugSymbolsType symbolsType = UnknownSymbols; QVector sectionHeaders; QVector programHeaders; }; diff --git a/src/libs/utils/environment.h b/src/libs/utils/environment.h index ea2dab24201..4803dda2a5c 100644 --- a/src/libs/utils/environment.h +++ b/src/libs/utils/environment.h @@ -82,7 +82,7 @@ QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug debug, const EnvironmentItem &i) class QTCREATOR_UTILS_EXPORT Environment { public: - typedef QMap::const_iterator const_iterator; + using const_iterator = QMap::const_iterator; explicit Environment(OsType osType = HostOsInfo::hostOs()) : m_osType(osType) {} explicit Environment(const QStringList &env, OsType osType = HostOsInfo::hostOs()); diff --git a/src/libs/utils/fancylineedit.h b/src/libs/utils/fancylineedit.h index 8ba5c14532b..e9753e269c2 100644 --- a/src/libs/utils/fancylineedit.h +++ b/src/libs/utils/fancylineedit.h @@ -121,7 +121,7 @@ public: // Validation // line edit, (out)errorMessage -> valid? - typedef std::function ValidationFunction; + using ValidationFunction = std::function; enum State { Invalid, DisplayingPlaceholderText, Valid }; State state() const; diff --git a/src/libs/utils/filesearch.h b/src/libs/utils/filesearch.h index a25949e2205..cddb637184f 100644 --- a/src/libs/utils/filesearch.h +++ b/src/libs/utils/filesearch.h @@ -65,26 +65,26 @@ public: class Item { public: - Item() : encoding(nullptr) { } + Item() = default; Item(const QString &path, QTextCodec *codec) : filePath(path), encoding(codec) {} QString filePath; - QTextCodec *encoding; + QTextCodec *encoding = nullptr; }; - typedef Item value_type; + using value_type = Item; class const_iterator { public: - typedef std::forward_iterator_tag iterator_category; - typedef Item value_type; - typedef std::ptrdiff_t difference_type; - typedef const value_type *pointer; - typedef const value_type &reference; + using iterator_category = std::forward_iterator_tag; + using value_type = Item; + using difference_type = std::ptrdiff_t; + using pointer = const value_type*; + using reference = const value_type&; - const_iterator() : m_parent(nullptr), m_index(-1) { } + const_iterator() = default; const_iterator(const FileIterator *parent, int id) : m_parent(parent), m_index(id) {} @@ -100,11 +100,11 @@ public: } bool operator!=(const const_iterator &other) const { return !operator==(other); } - const FileIterator *m_parent; - int m_index; // -1 == end + const FileIterator *m_parent = nullptr; + int m_index = -1; // -1 == end }; - virtual ~FileIterator() {} + virtual ~FileIterator() = default; const_iterator begin() const; const_iterator end() const; @@ -169,7 +169,7 @@ private: class QTCREATOR_UTILS_EXPORT FileSearchResult { public: - FileSearchResult() {} + FileSearchResult() = default; FileSearchResult(const QString &fileName, int lineNumber, const QString &matchingLine, int matchStart, int matchLength, const QStringList ®expCapturedTexts) @@ -189,7 +189,7 @@ public: QStringList regexpCapturedTexts; }; -typedef QList FileSearchResultList; +using FileSearchResultList = QList; QTCREATOR_UTILS_EXPORT QFuture findInFiles(const QString &searchTerm, FileIterator *files, QTextDocument::FindFlags flags, const QMap &fileToContentsMap = QMap()); diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index ccf1b50b0a0..48d87871002 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -395,10 +395,7 @@ bool FileReader::fetch(const QString &fileName, QIODevice::OpenMode mode, QWidge } #endif // QT_GUI_LIB -FileSaverBase::FileSaverBase() - : m_hasError(false) -{ -} +FileSaverBase::FileSaverBase() = default; FileSaverBase::~FileSaverBase() = default; @@ -526,7 +523,6 @@ bool FileSaver::finalize() } TempFileSaver::TempFileSaver(const QString &templ) - : m_autoRemove(true) { m_file.reset(new QTemporaryFile{}); auto tempFile = static_cast(m_file.get()); diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index 011069e1180..f6b0032f611 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -206,7 +206,7 @@ protected: std::unique_ptr m_file; QString m_fileName; QString m_errorString; - bool m_hasError; + bool m_hasError = false; private: Q_DISABLE_COPY(FileSaverBase) @@ -236,7 +236,7 @@ public: void setAutoRemove(bool on) { m_autoRemove = on; } private: - bool m_autoRemove; + bool m_autoRemove = true; }; } // namespace Utils diff --git a/src/libs/utils/fixedsizeclicklabel.cpp b/src/libs/utils/fixedsizeclicklabel.cpp index a648fd66e36..2e1ab89ef6f 100644 --- a/src/libs/utils/fixedsizeclicklabel.cpp +++ b/src/libs/utils/fixedsizeclicklabel.cpp @@ -58,7 +58,6 @@ namespace Utils { */ FixedSizeClickLabel::FixedSizeClickLabel(QWidget *parent) : QLabel(parent) - , m_pressed(false) { } diff --git a/src/libs/utils/fixedsizeclicklabel.h b/src/libs/utils/fixedsizeclicklabel.h index eb89de7ab92..93cf27cc9fb 100644 --- a/src/libs/utils/fixedsizeclicklabel.h +++ b/src/libs/utils/fixedsizeclicklabel.h @@ -54,7 +54,7 @@ signals: private: QString m_maxText; - bool m_pressed; + bool m_pressed = false; }; } // namespace Utils diff --git a/src/libs/utils/htmldocextractor.cpp b/src/libs/utils/htmldocextractor.cpp index e58accf8ef6..ac3246d2817 100644 --- a/src/libs/utils/htmldocextractor.cpp +++ b/src/libs/utils/htmldocextractor.cpp @@ -38,10 +38,7 @@ namespace { } } -HtmlDocExtractor::HtmlDocExtractor() : - m_formatContents(true), - m_mode(FirstParagraph) -{} +HtmlDocExtractor::HtmlDocExtractor() = default; void HtmlDocExtractor::setMode(Mode mode) { m_mode = mode; } diff --git a/src/libs/utils/htmldocextractor.h b/src/libs/utils/htmldocextractor.h index f7c82f54a1a..d4ede7d4eee 100644 --- a/src/libs/utils/htmldocextractor.h +++ b/src/libs/utils/htmldocextractor.h @@ -81,8 +81,8 @@ private: static void replaceTablesForSimpleLines(QString *html); static void replaceListsForSimpleLines(QString *html); - bool m_formatContents; - Mode m_mode; + bool m_formatContents = true; + Mode m_mode = FirstParagraph; }; } // namespace Utils diff --git a/src/libs/utils/icon.h b/src/libs/utils/icon.h index 5de0896653b..67c39ac4ee9 100644 --- a/src/libs/utils/icon.h +++ b/src/libs/utils/icon.h @@ -38,7 +38,7 @@ QT_FORWARD_DECLARE_CLASS(QString) namespace Utils { -typedef QPair IconMaskAndColor; +using IconMaskAndColor = QPair; // Returns a recolored icon with shadow and custom disabled state for a // series of grayscalemask|Theme::Color mask pairs diff --git a/src/libs/utils/json.h b/src/libs/utils/json.h index df7881a55e2..1179a0c967c 100644 --- a/src/libs/utils/json.h +++ b/src/libs/utils/json.h @@ -51,7 +51,7 @@ public: inline void *allocate(size_t size) { - char *obj = new char[size]; + auto obj = new char[size]; _objs.append(obj); return obj; } diff --git a/src/libs/utils/link.h b/src/libs/utils/link.h index d6df02c0760..6a87048eee6 100644 --- a/src/libs/utils/link.h +++ b/src/libs/utils/link.h @@ -35,9 +35,7 @@ namespace Utils { struct Link { Link(const QString &fileName = QString(), int line = 0, int column = 0) - : linkTextStart(-1) - , linkTextEnd(-1) - , targetFileName(fileName) + : targetFileName(fileName) , targetLine(line) , targetColumn(column) {} @@ -51,8 +49,8 @@ struct Link bool operator==(const Link &other) const { return linkTextStart == other.linkTextStart && linkTextEnd == other.linkTextEnd; } - int linkTextStart; - int linkTextEnd; + int linkTextStart = 1; + int linkTextEnd = -1; QString targetFileName; int targetLine; diff --git a/src/libs/utils/macroexpander.h b/src/libs/utils/macroexpander.h index ff96eb10899..f17ae86b8c2 100644 --- a/src/libs/utils/macroexpander.h +++ b/src/libs/utils/macroexpander.h @@ -38,8 +38,8 @@ namespace Utils { namespace Internal { class MacroExpanderPrivate; } class MacroExpander; -typedef std::function MacroExpanderProvider; -typedef QVector MacroExpanderProviders; +using MacroExpanderProvider = std::function; +using MacroExpanderProviders = QVector; class QTCREATOR_UTILS_EXPORT MacroExpander { @@ -59,10 +59,10 @@ public: QString expandProcessArgs(const QString &argsWithVariables) const; - typedef std::function PrefixFunction; - typedef std::function ResolverFunction; - typedef std::function StringFunction; - typedef std::function IntFunction; + using PrefixFunction = std::function; + using ResolverFunction = std::function; + using StringFunction = std::function; + using IntFunction = std::function; void registerPrefix(const QByteArray &prefix, const QString &description, const PrefixFunction &value); diff --git a/src/libs/utils/overridecursor.cpp b/src/libs/utils/overridecursor.cpp index 4c9093917fd..7868289725d 100644 --- a/src/libs/utils/overridecursor.cpp +++ b/src/libs/utils/overridecursor.cpp @@ -30,7 +30,7 @@ using namespace Utils; OverrideCursor::OverrideCursor(const QCursor &cursor) - : m_set(true), m_cursor(cursor) + : m_cursor(cursor) { QApplication::setOverrideCursor(cursor); } diff --git a/src/libs/utils/overridecursor.h b/src/libs/utils/overridecursor.h index 5ca2bb58002..00ce021fe24 100644 --- a/src/libs/utils/overridecursor.h +++ b/src/libs/utils/overridecursor.h @@ -39,7 +39,7 @@ public: void set(); void reset(); private: - bool m_set; + bool m_set = true; QCursor m_cursor; }; diff --git a/src/libs/utils/port.h b/src/libs/utils/port.h index 0ed62d0a9b4..56d0b646dc0 100644 --- a/src/libs/utils/port.h +++ b/src/libs/utils/port.h @@ -38,7 +38,7 @@ namespace Utils { class QTCREATOR_UTILS_EXPORT Port { public: - Port() : m_port(-1) {} + Port() = default; explicit Port(quint16 port) : m_port(port) {} explicit Port(int port) : m_port((port < 0 || port > std::numeric_limits::max()) ? -1 : port) @@ -56,7 +56,7 @@ public: QString toString() const { return QString::number(m_port); } private: - int m_port; + int m_port = -1; }; inline bool operator<(const Port &p1, const Port &p2) { return p1.number() < p2.number(); } diff --git a/src/libs/utils/proxyaction.cpp b/src/libs/utils/proxyaction.cpp index 3bfbfa399c2..67917e71b10 100644 --- a/src/libs/utils/proxyaction.cpp +++ b/src/libs/utils/proxyaction.cpp @@ -28,11 +28,7 @@ using namespace Utils; ProxyAction::ProxyAction(QObject *parent) : - QAction(parent), - m_action(nullptr), - m_attributes(nullptr), - m_showShortcut(false), - m_block(false) + QAction(parent) { connect(this, &QAction::changed, this, &ProxyAction::updateToolTipWithKeySequence); updateState(); diff --git a/src/libs/utils/proxyaction.h b/src/libs/utils/proxyaction.h index 5058bb42f3d..6f5671cea78 100644 --- a/src/libs/utils/proxyaction.h +++ b/src/libs/utils/proxyaction.h @@ -68,11 +68,11 @@ private: void connectAction(); void update(QAction *action, bool initialize); - QPointer m_action; - Attributes m_attributes; - bool m_showShortcut; + QPointer m_action = nullptr; + Attributes m_attributes = {}; + bool m_showShortcut = false; QString m_toolTip; - bool m_block; + bool m_block = false; }; } // namespace Utils diff --git a/src/libs/utils/qtcprocess.cpp b/src/libs/utils/qtcprocess.cpp index eb9cf9f6472..dd4fe16f49a 100644 --- a/src/libs/utils/qtcprocess.cpp +++ b/src/libs/utils/qtcprocess.cpp @@ -668,9 +668,7 @@ bool QtcProcess::prepareCommand(const QString &command, const QString &arguments } QtcProcess::QtcProcess(QObject *parent) - : QProcess(parent), - m_haveEnv(false), - m_useCtrlCStub(false) + : QProcess(parent) { static int qProcessExitStatusMeta = qRegisterMetaType(); static int qProcessProcessErrorMeta = qRegisterMetaType(); diff --git a/src/libs/utils/qtcprocess.h b/src/libs/utils/qtcprocess.h index 4ff75a7daef..44c57866611 100644 --- a/src/libs/utils/qtcprocess.h +++ b/src/libs/utils/qtcprocess.h @@ -106,7 +106,7 @@ public: class QTCREATOR_UTILS_EXPORT ArgIterator { public: ArgIterator(QString *str, OsType osType = HostOsInfo::hostOs()) - : m_str(str), m_pos(0), m_prev(-1), m_osType(osType) + : m_str(str), m_osType(osType) {} //! Get the next argument. Returns false on encountering end of first command. bool next(); @@ -121,7 +121,8 @@ public: void appendArg(const QString &str); private: QString *m_str, m_value; - int m_pos, m_prev; + int m_pos = 0; + int m_prev = -1; bool m_simple; OsType m_osType; }; @@ -143,8 +144,8 @@ private: QString m_command; QString m_arguments; Environment m_environment; - bool m_haveEnv; - bool m_useCtrlCStub; + bool m_haveEnv = false; + bool m_useCtrlCStub = false; }; } // namespace Utils diff --git a/src/libs/utils/savedaction.cpp b/src/libs/utils/savedaction.cpp index a1b3aac0e38..0000e54d317 100644 --- a/src/libs/utils/savedaction.cpp +++ b/src/libs/utils/savedaction.cpp @@ -56,7 +56,6 @@ namespace Utils { SavedAction::SavedAction(QObject *parent) : QAction(parent) { - m_widget = nullptr; connect(this, &QAction::triggered, this, &SavedAction::actionTriggered); } diff --git a/src/libs/utils/savedaction.h b/src/libs/utils/savedaction.h index 45454939f19..5f90de65ed4 100644 --- a/src/libs/utils/savedaction.h +++ b/src/libs/utils/savedaction.h @@ -83,14 +83,14 @@ private: QString m_settingsKey; QString m_settingsGroup; QString m_dialogText; - QWidget *m_widget; + QWidget *m_widget = nullptr; }; class QTCREATOR_UTILS_EXPORT SavedActionSet { public: - SavedActionSet() {} - ~SavedActionSet() {} + SavedActionSet() = default; + ~SavedActionSet() = default; void insert(SavedAction *action, QWidget *widget); void apply(QSettings *settings); diff --git a/src/libs/utils/savefile.cpp b/src/libs/utils/savefile.cpp index 6413a823cee..36b515568ec 100644 --- a/src/libs/utils/savefile.cpp +++ b/src/libs/utils/savefile.cpp @@ -39,7 +39,7 @@ namespace Utils { QFile::Permissions SaveFile::m_umask = nullptr; SaveFile::SaveFile(const QString &filename) : - m_finalFileName(filename), m_finalized(true) + m_finalFileName(filename) { } diff --git a/src/libs/utils/savefile.h b/src/libs/utils/savefile.h index 56d60aacc94..799b30c9ca8 100644 --- a/src/libs/utils/savefile.h +++ b/src/libs/utils/savefile.h @@ -51,7 +51,7 @@ public: private: const QString m_finalFileName; std::unique_ptr m_tempFile; - bool m_finalized; + bool m_finalized = true; static QFile::Permissions m_umask; }; diff --git a/src/libs/utils/scopedswap.h b/src/libs/utils/scopedswap.h index 4cc129bd218..46384448bc7 100644 --- a/src/libs/utils/scopedswap.h +++ b/src/libs/utils/scopedswap.h @@ -49,6 +49,6 @@ public: } }; -typedef ScopedSwap ScopedBoolSwap; +using ScopedBoolSwap = ScopedSwap; } // Utils namespace diff --git a/src/libs/utils/settingsaccessor.h b/src/libs/utils/settingsaccessor.h index e4310865536..10675cbf4c0 100644 --- a/src/libs/utils/settingsaccessor.h +++ b/src/libs/utils/settingsaccessor.h @@ -78,7 +78,7 @@ public: virtual ~SettingsAccessor() = default; enum ProceedInfo { Continue, DiscardAndContinue }; - typedef QHash ButtonMap; + using ButtonMap = QHash; class Issue { public: enum class Type { ERROR, WARNING }; @@ -224,7 +224,7 @@ public: virtual QVariantMap upgrade(const QVariantMap &data) = 0; protected: - typedef QPair Change; + using Change = QPair; QVariantMap renameKeys(const QList &changes, QVariantMap map) const; private: diff --git a/src/libs/utils/settingsselector.h b/src/libs/utils/settingsselector.h index 7c5220afadc..16d98e40c7f 100644 --- a/src/libs/utils/settingsselector.h +++ b/src/libs/utils/settingsselector.h @@ -46,8 +46,8 @@ class QTCREATOR_UTILS_EXPORT SettingsSelector : public QWidget Q_OBJECT public: - explicit SettingsSelector(QWidget *parent = 0); - ~SettingsSelector(); + explicit SettingsSelector(QWidget *parent = nullptr); + ~SettingsSelector() override; void setConfigurationModel(QAbstractItemModel *model); QAbstractItemModel *configurationModel() const; diff --git a/src/libs/utils/shellcommand.cpp b/src/libs/utils/shellcommand.cpp index d44b5bd982a..92d97dc65b4 100644 --- a/src/libs/utils/shellcommand.cpp +++ b/src/libs/utils/shellcommand.cpp @@ -503,7 +503,6 @@ void ShellCommand::setOutputProxyFactory(const std::function &f } ProgressParser::ProgressParser() : - m_future(nullptr), m_futureMutex(new QMutex) { } diff --git a/src/libs/utils/shellcommand.h b/src/libs/utils/shellcommand.h index 3f933ee1146..9bd5c04a41a 100644 --- a/src/libs/utils/shellcommand.h +++ b/src/libs/utils/shellcommand.h @@ -63,7 +63,7 @@ private: void setFuture(QFutureInterface *future); QFutureInterface *m_future; - QMutex *m_futureMutex; + QMutex *m_futureMutex = nullptr; friend class ShellCommand; }; diff --git a/src/libs/utils/statuslabel.cpp b/src/libs/utils/statuslabel.cpp index c9b6317fdf7..ff4a63843da 100644 --- a/src/libs/utils/statuslabel.cpp +++ b/src/libs/utils/statuslabel.cpp @@ -35,7 +35,7 @@ namespace Utils { -StatusLabel::StatusLabel(QWidget *parent) : QLabel(parent), m_timer(nullptr) +StatusLabel::StatusLabel(QWidget *parent) : QLabel(parent) { // A manual size let's us shrink below minimum text width which is what // we want in [fake] status bars. diff --git a/src/libs/utils/statuslabel.h b/src/libs/utils/statuslabel.h index 470040d5724..054330b0853 100644 --- a/src/libs/utils/statuslabel.h +++ b/src/libs/utils/statuslabel.h @@ -47,7 +47,7 @@ private: void slotTimeout(); void stopTimer(); - QTimer *m_timer; + QTimer *m_timer = nullptr; QString m_lastPermanentStatusMessage; }; diff --git a/src/libs/utils/synchronousprocess.cpp b/src/libs/utils/synchronousprocess.cpp index 6f1f90d0823..0f8d4ea8258 100644 --- a/src/libs/utils/synchronousprocess.cpp +++ b/src/libs/utils/synchronousprocess.cpp @@ -84,7 +84,7 @@ namespace Utils { // A special QProcess derivative allowing for terminal control. class TerminalControllingProcess : public QProcess { public: - TerminalControllingProcess() : m_flags(0) {} + TerminalControllingProcess() = default; unsigned flags() const { return m_flags; } void setFlags(unsigned tc) { m_flags = tc; } @@ -93,7 +93,7 @@ protected: void setupChildProcess() override; private: - unsigned m_flags; + unsigned m_flags = 0; }; void TerminalControllingProcess::setupChildProcess() diff --git a/src/libs/utils/textfileformat.cpp b/src/libs/utils/textfileformat.cpp index 4dc281d8a35..afd4e62e830 100644 --- a/src/libs/utils/textfileformat.cpp +++ b/src/libs/utils/textfileformat.cpp @@ -68,10 +68,7 @@ QDebug operator<<(QDebug d, const TextFileFormat &format) as strings or string lists and to write out files. */ -TextFileFormat::TextFileFormat() : - lineTerminationMode(NativeLineTerminator), hasUtf8Bom(false), codec(nullptr) -{ -} +TextFileFormat::TextFileFormat() = default; /*! Detects the format of text data. diff --git a/src/libs/utils/textfileformat.h b/src/libs/utils/textfileformat.h index ab432a53d6d..9ac452a6e5a 100644 --- a/src/libs/utils/textfileformat.h +++ b/src/libs/utils/textfileformat.h @@ -78,9 +78,9 @@ public: static QByteArray decodingErrorSample(const QByteArray &data); - LineTerminationMode lineTerminationMode; - bool hasUtf8Bom; - const QTextCodec *codec; + LineTerminationMode lineTerminationMode = NativeLineTerminator; + bool hasUtf8Bom = false; + const QTextCodec *codec = nullptr; }; } // namespace Utils diff --git a/src/libs/utils/treemodel.cpp b/src/libs/utils/treemodel.cpp index f5ed3b251d6..0d587dddbc7 100644 --- a/src/libs/utils/treemodel.cpp +++ b/src/libs/utils/treemodel.cpp @@ -605,10 +605,7 @@ namespace Utils { // // TreeItem // -TreeItem::TreeItem() - : m_parent(nullptr), m_model(nullptr) -{ -} +TreeItem::TreeItem() = default; TreeItem::~TreeItem() { diff --git a/src/libs/utils/treemodel.h b/src/libs/utils/treemodel.h index bf20b75c8d2..92f501ff4a6 100644 --- a/src/libs/utils/treemodel.h +++ b/src/libs/utils/treemodel.h @@ -99,8 +99,8 @@ private: void removeItemAt(int pos); void propagateModel(BaseTreeModel *m); - TreeItem *m_parent; // Not owned. - BaseTreeModel *m_model; // Not owned. + TreeItem *m_parent = nullptr; // Not owned. + BaseTreeModel *m_model = nullptr; // Not owned. QVector m_children; // Owned. friend class BaseTreeModel; }; diff --git a/src/libs/utils/treeviewcombobox.cpp b/src/libs/utils/treeviewcombobox.cpp index 4f20bab5373..36a62d36943 100644 --- a/src/libs/utils/treeviewcombobox.cpp +++ b/src/libs/utils/treeviewcombobox.cpp @@ -44,7 +44,7 @@ void TreeViewComboBoxView::adjustWidth(int width) TreeViewComboBox::TreeViewComboBox(QWidget *parent) - : QComboBox(parent), m_skipNextHide(false) + : QComboBox(parent) { m_view = new TreeViewComboBoxView; m_view->setHeaderHidden(true); diff --git a/src/libs/utils/treeviewcombobox.h b/src/libs/utils/treeviewcombobox.h index 0bdfc73cbb0..08ab5d72263 100644 --- a/src/libs/utils/treeviewcombobox.h +++ b/src/libs/utils/treeviewcombobox.h @@ -61,6 +61,6 @@ private: QModelIndex lastIndex(const QModelIndex &index); TreeViewComboBoxView *m_view; - bool m_skipNextHide; + bool m_skipNextHide = false; }; } diff --git a/src/libs/utils/uncommentselection.cpp b/src/libs/utils/uncommentselection.cpp index 852bea627a7..6771f3f4ea4 100644 --- a/src/libs/utils/uncommentselection.cpp +++ b/src/libs/utils/uncommentselection.cpp @@ -32,14 +32,11 @@ using namespace Utils; CommentDefinition CommentDefinition::CppStyle = CommentDefinition("//", "/*", "*/"); CommentDefinition CommentDefinition::HashStyle = CommentDefinition("#"); -CommentDefinition::CommentDefinition() : - isAfterWhiteSpaces(false) -{} +CommentDefinition::CommentDefinition() = default; CommentDefinition::CommentDefinition(const QString &single, const QString &multiStart, const QString &multiEnd) - : isAfterWhiteSpaces(false), - singleLine(single), + : singleLine(single), multiLineStart(multiStart), multiLineEnd(multiEnd) { diff --git a/src/libs/utils/uncommentselection.h b/src/libs/utils/uncommentselection.h index dbc47bbc646..b61fce48c91 100644 --- a/src/libs/utils/uncommentselection.h +++ b/src/libs/utils/uncommentselection.h @@ -50,7 +50,7 @@ public: bool hasMultiLineStyle() const; public: - bool isAfterWhiteSpaces; + bool isAfterWhiteSpaces = false; QString singleLine; QString multiLineStart; QString multiLineEnd; diff --git a/src/libs/utils/wizard.cpp b/src/libs/utils/wizard.cpp index 4d83a381e59..a1c0e2fb687 100644 --- a/src/libs/utils/wizard.cpp +++ b/src/libs/utils/wizard.cpp @@ -565,12 +565,7 @@ class WizardProgressPrivate Q_DECLARE_PUBLIC(WizardProgress) public: - WizardProgressPrivate() - : - m_currentItem(nullptr), - m_startItem(nullptr) - { - } + WizardProgressPrivate() = default; bool isNextItem(WizardProgressItem *item, WizardProgressItem *nextItem) const; // if multiple paths are possible the empty list is returned @@ -585,8 +580,8 @@ public: QList m_visitedItems; QList m_reachableItems; - WizardProgressItem *m_currentItem; - WizardProgressItem *m_startItem; + WizardProgressItem *m_currentItem = nullptr; + WizardProgressItem *m_startItem = nullptr; }; class WizardProgressItemPrivate