diff --git a/src/bookmarkswidget.cpp b/src/bookmarkswidget.cpp index 387d0a5e..bab8f4db 100644 --- a/src/bookmarkswidget.cpp +++ b/src/bookmarkswidget.cpp @@ -193,8 +193,7 @@ BookmarksModel::BookmarksModel(QObject *parent) void BookmarksModel::setup() { - if (m_root) - delete m_root; + delete m_root; m_root = new BookmarkRootItem(); m_root->addChild(new BookmarkFileGroupItem(m_root, Properties::Instance()->bookmarksFile)); beginResetModel(); @@ -203,8 +202,8 @@ void BookmarksModel::setup() BookmarksModel::~BookmarksModel() { - if (m_root) - delete m_root; + delete m_root; + m_root = nullptr; } int BookmarksModel::columnCount(const QModelIndex & /* parent */) const @@ -323,10 +322,10 @@ bool BookmarksModel::setData(const QModelIndex &index, const QVariant &value, BookmarksWidget::BookmarksWidget(QWidget *parent) : QWidget(parent) + , m_model(new BookmarksModel(this)) { setupUi(this); - m_model = new BookmarksModel(this); treeView->setModel(m_model); treeView->header()->hide(); setFocusProxy(filterEdit); @@ -342,9 +341,7 @@ BookmarksWidget::BookmarksWidget(QWidget *parent) }); } -BookmarksWidget::~BookmarksWidget() -{ -} +BookmarksWidget::~BookmarksWidget() = default; void BookmarksWidget::setup() { diff --git a/src/main.cpp b/src/main.cpp index dee72544..f436749d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,7 +26,6 @@ #include #ifdef HAVE_QDBUS #include - #include #include "processadaptor.h" #endif @@ -75,7 +74,7 @@ QTerminalApp * QTerminalApp::m_instance = nullptr; void parse_args(int argc, char* argv[], QString& workdir, QStringList & shell_command, out bool& dropMode) { - int next_option; + int next_option = 0; dropMode = false; do{ next_option = getopt_long(argc, argv, short_options, long_options, nullptr); @@ -144,7 +143,7 @@ int main(int argc, char *argv[]) QString workdir; QStringList shell_command; - bool dropMode; + bool dropMode = false; parse_args(argc, argv, workdir, shell_command, dropMode); Properties::Instance()->migrate_settings(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 18042ef2..44f9d27c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -914,7 +914,7 @@ bool MainWindow::hasMultipleSubterminals(QAction *) bool MainWindow::hasIndexedTab(QAction *action) { - bool ok; + bool ok = false; const int index = action->property("tab").toInt(&ok); Q_ASSERT(ok); static_cast(ok); diff --git a/src/propertiesdialog.cpp b/src/propertiesdialog.cpp index 68565f0b..a64899dc 100644 --- a/src/propertiesdialog.cpp +++ b/src/propertiesdialog.cpp @@ -299,10 +299,7 @@ PropertiesDialog::PropertiesDialog(QWidget *parent) resize(s); } - -PropertiesDialog::~PropertiesDialog() -{ -} +PropertiesDialog::~PropertiesDialog() = default; void PropertiesDialog::accept() { diff --git a/src/qterminalutils.cpp b/src/qterminalutils.cpp index 62ce95e2..fcb671e2 100644 --- a/src/qterminalutils.cpp +++ b/src/qterminalutils.cpp @@ -29,7 +29,7 @@ QStringList parse_command(const QString& str) QStringList list; QRegularExpressionMatch match; int index = 0; - int nextIndex; + int nextIndex = 0; while((nextIndex = str.indexOf(separator, index, &match)) != -1) { if (nextIndex > index) diff --git a/src/tab-switcher.cpp b/src/tab-switcher.cpp index 1a8f4710..f91f02ab 100644 --- a/src/tab-switcher.cpp +++ b/src/tab-switcher.cpp @@ -89,23 +89,22 @@ class AppItemDelegate: public QStyledItemDelegate // ----------------------------------------------------------------------------------------------------------- -TabSwitcher::TabSwitcher(TabWidget* tabs): - QListView(tabs), - m_tabs(tabs) +TabSwitcher::TabSwitcher(TabWidget *tabs) + : QListView(tabs) + , m_timer(new QTimer(this)) + , m_tabs(tabs) { setWindowFlags(Qt::Widget | Qt::Popup | Qt::WindowStaysOnTopHint); setItemDelegate(new AppItemDelegate(frameWidth(), tabs)); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_timer = new QTimer(this); m_timer->setInterval(100); m_timer->setSingleShot(true); connect(m_timer, &QTimer::timeout, this, &TabSwitcher::timer); } -TabSwitcher::~TabSwitcher() -{} +TabSwitcher::~TabSwitcher() = default; void TabSwitcher::showSwitcher() { diff --git a/src/terminalconfig.cpp b/src/terminalconfig.cpp index 1497a298..5e30ce88 100644 --- a/src/terminalconfig.cpp +++ b/src/terminalconfig.cpp @@ -8,15 +8,13 @@ #include "properties.h" #include "termwidget.h" -TerminalConfig::TerminalConfig(const QString & wdir, const QStringList & shell) +TerminalConfig::TerminalConfig(const QString &wdir, const QStringList &shell) + : m_workingDirectory(wdir) + , m_shell(shell) { - m_workingDirectory = wdir; - m_shell = shell; } -TerminalConfig::TerminalConfig() -{ -} +TerminalConfig::TerminalConfig() = default; TerminalConfig::TerminalConfig(const TerminalConfig &cfg) : m_currentDirectory(cfg.m_currentDirectory), diff --git a/src/termwidget.cpp b/src/termwidget.cpp index 309b3847..935c4dd5 100644 --- a/src/termwidget.cpp +++ b/src/termwidget.cpp @@ -268,19 +268,20 @@ bool TermWidget::eventFilter(QObject * /*obj*/, QEvent * ev) return false; } -TermWidget::TermWidget(TerminalConfig &cfg, QWidget * parent) - : QWidget(parent), - DBusAddressable(QStringLiteral("/terminals")) +TermWidget::TermWidget(TerminalConfig &cfg, QWidget *parent) + : QWidget(parent) + , DBusAddressable(QStringLiteral("/terminals")) + , m_term(new TermWidgetImpl(cfg, this)) + , m_layout(new QVBoxLayout) + , m_border(palette().color(QPalette::Window)) { #ifdef HAVE_QDBUS registerAdapter(this); #endif - m_border = palette().color(QPalette::Window); - m_term = new TermWidgetImpl(cfg, this); + setFocusProxy(m_term); - m_layout = new QVBoxLayout; setLayout(m_layout); m_layout->addWidget(m_term); diff --git a/src/termwidgetholder.cpp b/src/termwidgetholder.cpp index 95c556c4..c0456d45 100644 --- a/src/termwidgetholder.cpp +++ b/src/termwidgetholder.cpp @@ -61,9 +61,7 @@ TermWidgetHolder::TermWidgetHolder(TerminalConfig &config, QWidget * parent) setLayout(lay); } -TermWidgetHolder::~TermWidgetHolder() -{ -} +TermWidgetHolder::~TermWidgetHolder() = default; void TermWidgetHolder::setInitialFocus() { @@ -75,7 +73,7 @@ void TermWidgetHolder::setInitialFocus() void TermWidgetHolder::loadSession() { - bool ok; + bool ok = false; QString name = QInputDialog::getItem(this, tr("Load Session"), tr("List of saved sessions:"), Properties::Instance()->sessions.keys(),