From a540e6fdd0f45a1b762ea72dd2dcd79a5b10df12 Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Fri, 21 Apr 2017 10:51:31 -0400 Subject: [PATCH] Fix readability-implicit-bool-cast issues using nullptr --- src/Application.cpp | 2 +- src/BookmarkHandler.cpp | 6 +- src/ColorScheme.cpp | 10 ++-- src/ColorSchemeEditor.cpp | 2 +- src/CopyInputDialog.cpp | 4 +- src/EditProfileDialog.cpp | 24 ++++---- src/Emulation.cpp | 4 +- src/ExtendedCharTable.cpp | 2 +- src/Filter.cpp | 8 +-- src/History.cpp | 14 ++--- src/KeyBindingEditor.cpp | 2 +- src/KeyboardTranslatorManager.cpp | 2 +- src/MainWindow.cpp | 24 ++++---- src/Part.cpp | 4 +- src/ProcessInfo.cpp | 2 +- src/ProfileList.cpp | 6 +- src/Screen.cpp | 2 +- src/Session.cpp | 14 ++--- src/SessionController.cpp | 64 ++++++++++---------- src/TerminalCharacterDecoder.cpp | 8 +-- src/TerminalDisplay.cpp | 78 ++++++++++++------------- src/TerminalDisplayAccessible.cpp | 16 ++--- src/ViewContainer.cpp | 12 ++-- src/ViewContainerTabBar.cpp | 6 +- src/ViewManager.cpp | 60 +++++++++---------- src/ViewSplitter.cpp | 8 +-- src/Vt102Emulation.cpp | 4 +- src/autotests/DBusTest.cpp | 2 +- src/autotests/PartTest.cpp | 4 +- src/autotests/TerminalInterfaceTest.cpp | 6 +- src/settings/ProfileSettings.cpp | 8 +-- 31 files changed, 204 insertions(+), 204 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 57b8c2650..ef5ef6fc0 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -523,7 +523,7 @@ Profile::Ptr Application::processProfileChangeArgs(Profile::Ptr baseProfile) void Application::startBackgroundMode(MainWindow* window) { - if (_backgroundInstance) { + if (_backgroundInstance != nullptr) { return; } diff --git a/src/BookmarkHandler.cpp b/src/BookmarkHandler.cpp index 80ac8e725..b124db4a0 100644 --- a/src/BookmarkHandler.cpp +++ b/src/BookmarkHandler.cpp @@ -101,7 +101,7 @@ QUrl BookmarkHandler::currentUrl() const QUrl BookmarkHandler::urlForView(ViewProperties* view) const { - if (view) + if (view != nullptr) return QUrl(view->url()); else return QUrl(); @@ -114,7 +114,7 @@ QString BookmarkHandler::currentTitle() const QString BookmarkHandler::titleForView(ViewProperties* view) const { - const QUrl& url = view ? view->url() : QUrl(); + const QUrl& url = view != nullptr ? view->url() : QUrl(); if (url.isLocalFile()) { QString path = url.path(); @@ -139,7 +139,7 @@ QString BookmarkHandler::currentIcon() const QString BookmarkHandler::iconForView(ViewProperties* view) const { - if (view) + if (view != nullptr) return view->icon().name(); else return QString(); diff --git a/src/ColorScheme.cpp b/src/ColorScheme.cpp index 3bb5186b2..c3369be1a 100644 --- a/src/ColorScheme.cpp +++ b/src/ColorScheme.cpp @@ -219,7 +219,7 @@ void ColorScheme::setColorTableEntry(int index , const ColorEntry& entry) { Q_ASSERT(index >= 0 && index < TABLE_COLORS); - if (!_table) { + if (_table == nullptr) { _table = new ColorEntry[TABLE_COLORS]; for (int i = 0; i < TABLE_COLORS; i++) @@ -292,7 +292,7 @@ void ColorScheme::setRandomizedBackgroundColor(bool randomize) if (randomize) { setRandomizationRange(BGCOLOR_INDEX , MAX_HUE , 255 , 0); } else { - if (_randomTable) + if (_randomTable != nullptr) setRandomizationRange(BGCOLOR_INDEX , 0 , 0 , 0); } } @@ -313,7 +313,7 @@ void ColorScheme::setRandomizationRange(int index , quint16 hue , quint8 saturat const ColorEntry* ColorScheme::colorTable() const { - if (_table) + if (_table != nullptr) return _table; else return defaultTable; @@ -449,7 +449,7 @@ void ColorSchemeWallpaper::load() return; // Create and load original pixmap - if (!_picture) + if (_picture == nullptr) _picture = new QPixmap(); if (_picture->isNull()) @@ -463,7 +463,7 @@ bool ColorSchemeWallpaper::isNull() const bool ColorSchemeWallpaper::draw(QPainter& painter, const QRect& rect, qreal opacity) { - if (!_picture || _picture->isNull()) + if ((_picture == nullptr) || _picture->isNull()) return false; if (qFuzzyCompare(1.0, opacity)) { diff --git a/src/ColorSchemeEditor.cpp b/src/ColorSchemeEditor.cpp index ccf3d7e91..a6da53ff6 100644 --- a/src/ColorSchemeEditor.cpp +++ b/src/ColorSchemeEditor.cpp @@ -209,7 +209,7 @@ void ColorSchemeEditor::wallpaperPathChanged(const QString& path) } void ColorSchemeEditor::setDescription(const QString& text) { - if (_colors) + if (_colors != nullptr) _colors->setDescription(text); if (_ui->descriptionEdit->text() != text) diff --git a/src/CopyInputDialog.cpp b/src/CopyInputDialog.cpp index 8e2d6b4c2..da7195aa6 100644 --- a/src/CopyInputDialog.cpp +++ b/src/CopyInputDialog.cpp @@ -85,7 +85,7 @@ CopyInputDialog::~CopyInputDialog() void CopyInputDialog::setChosenSessions(const QSet& sessions) { QSet checked = sessions; - if (_masterSession) + if (_masterSession != nullptr) checked.insert(_masterSession); _model->setCheckedSessions(checked); @@ -96,7 +96,7 @@ QSet CopyInputDialog::chosenSessions() const } void CopyInputDialog::setMasterSession(Session* session) { - if (_masterSession) + if (_masterSession != nullptr) _model->setCheckable(_masterSession, true); _model->setCheckable(session, false); diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp index 0ed4e2d5d..fb6e5bd88 100644 --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -490,7 +490,7 @@ void EditProfileDialog::toggleMouseWheelZoom(bool enable) } void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme) { - if (!_ui->colorSchemeList->model()) + if (_ui->colorSchemeList->model() == nullptr) _ui->colorSchemeList->setModel(new QStandardItemModel(this)); const QString& name = lookupProfile()->colorScheme(); @@ -520,7 +520,7 @@ void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme) model->sort(0); - if (selectCurrentScheme && selectedItem) { + if (selectCurrentScheme && (selectedItem != nullptr)) { _ui->colorSchemeList->updateGeometry(); _ui->colorSchemeList->selectionModel()->setCurrentIndex(selectedItem->index() , QItemSelectionModel::Select); @@ -531,7 +531,7 @@ void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme) } void EditProfileDialog::updateKeyBindingsList(bool selectCurrentTranslator) { - if (!_ui->keyBindingList->model()) + if (_ui->keyBindingList->model() == nullptr) _ui->keyBindingList->setModel(new QStandardItemModel(this)); const QString& name = lookupProfile()->keyBindings(); @@ -550,7 +550,7 @@ void EditProfileDialog::updateKeyBindingsList(bool selectCurrentTranslator) QStringList translatorNames = keyManager->allTranslators(); foreach(const QString& translatorName, translatorNames) { const KeyboardTranslator* translator = keyManager->findTranslator(translatorName); - if (!translator) continue; + if (translator == nullptr) continue; QStandardItem* item = new QStandardItem(translator->description()); item->setEditable(false); @@ -566,7 +566,7 @@ void EditProfileDialog::updateKeyBindingsList(bool selectCurrentTranslator) model->sort(0); - if (selectCurrentTranslator && selectedItem) { + if (selectCurrentTranslator && (selectedItem != nullptr)) { _ui->keyBindingList->selectionModel()->setCurrentIndex(selectedItem->index() , QItemSelectionModel::Select); } @@ -689,7 +689,7 @@ void EditProfileDialog::showColorSchemeEditor(bool isNewScheme) // Setting up ColorSchemeEditor ui // close any running ColorSchemeEditor - if (_colorDialog) { + if (_colorDialog != nullptr) { closeColorSchemeEditor(); } _colorDialog = new ColorSchemeEditor(this); @@ -701,7 +701,7 @@ void EditProfileDialog::showColorSchemeEditor(bool isNewScheme) } void EditProfileDialog::closeColorSchemeEditor() { - if (_colorDialog) { + if (_colorDialog != nullptr) { _colorDialog->close(); delete _colorDialog; } @@ -736,7 +736,7 @@ void EditProfileDialog::colorSchemeSelected() if (!selected.isEmpty()) { QAbstractItemModel* model = _ui->colorSchemeList->model(); const ColorScheme* colors = model->data(selected.first(), Qt::UserRole + 1).value(); - if (colors) { + if (colors != nullptr) { updateTempProfileProperty(Profile::ColorScheme, colors->name()); previewColorScheme(selected.first()); @@ -841,7 +841,7 @@ void EditProfileDialog::keyBindingSelected() QAbstractItemModel* model = _ui->keyBindingList->model(); const KeyboardTranslator* translator = model->data(selected.first(), Qt::UserRole + 1) .value(); - if (translator) { + if (translator != nullptr) { updateTempProfileProperty(Profile::KeyBindings, translator->name()); } } @@ -885,7 +885,7 @@ void EditProfileDialog::showKeyBindingEditor(bool isNewTranslator) auto editor = new KeyBindingEditor; - if (translator) + if (translator != nullptr) editor->setup(translator); if (isNewTranslator) @@ -1295,13 +1295,13 @@ void ColorSchemeViewDelegate::paint(QPainter* painter, const QStyleOptionViewIte const ColorScheme* scheme = index.data(Qt::UserRole + 1).value(); QFont profileFont = index.data(Qt::UserRole + 2).value(); Q_ASSERT(scheme); - if (!scheme) + if (scheme == nullptr) return; painter->setRenderHint(QPainter::Antialiasing); // Draw background - QStyle *style = option.widget ? option.widget->style() : QApplication::style(); + QStyle *style = option.widget != nullptr ? option.widget->style() : QApplication::style(); style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, option.widget); // Draw name diff --git a/src/Emulation.cpp b/src/Emulation.cpp index 2e9dbe8e6..8fd360fe9 100644 --- a/src/Emulation.cpp +++ b/src/Emulation.cpp @@ -143,7 +143,7 @@ const HistoryType& Emulation::history() const void Emulation::setCodec(const QTextCodec * codec) { - if (codec) { + if (codec != nullptr) { _codec = codec; delete _decoder; @@ -166,7 +166,7 @@ void Emulation::setCodec(EmulationCodec codec) void Emulation::setKeyBindings(const QString& name) { _keyTranslator = KeyboardTranslatorManager::instance()->findTranslator(name); - if (!_keyTranslator) { + if (_keyTranslator == nullptr) { _keyTranslator = KeyboardTranslatorManager::instance()->defaultTranslator(); } } diff --git a/src/ExtendedCharTable.cpp b/src/ExtendedCharTable.cpp index c07d6dd11..44b037fa0 100644 --- a/src/ExtendedCharTable.cpp +++ b/src/ExtendedCharTable.cpp @@ -115,7 +115,7 @@ ushort* ExtendedCharTable::lookupExtendedChar(ushort hash , ushort& length) cons // argument and return a pointer to the character sequence ushort* buffer = extendedCharTable[hash]; - if (buffer) { + if (buffer != nullptr) { length = buffer[0]; return buffer + 1; } else { diff --git a/src/Filter.cpp b/src/Filter.cpp index 989db3678..1900e48a3 100644 --- a/src/Filter.cpp +++ b/src/Filter.cpp @@ -358,7 +358,7 @@ void RegExpFilter::process() RegExpFilter::HotSpot* spot = newHotSpot(startLine, startColumn, endLine, endColumn, match.capturedTexts()); - if (!spot) { + if (spot == nullptr) { continue; } @@ -405,14 +405,14 @@ void UrlFilter::HotSpot::activate(QObject* object) const UrlType kind = urlType(); - const QString& actionName = object ? object->objectName() : QString(); + const QString& actionName = object != nullptr ? object->objectName() : QString(); if (actionName == QLatin1String("copy-action")) { QApplication::clipboard()->setText(url); return; } - if (!object || actionName == QLatin1String("open-action")) { + if ((object == nullptr) || actionName == QLatin1String("open-action")) { if (kind == StandardUrl) { // if the URL path does not include the protocol ( eg. "www.kde.org" ) then // prepend http:// ( eg. "www.kde.org" --> "http://www.kde.org" ) @@ -501,7 +501,7 @@ QList UrlFilter::HotSpot::actions() RegExpFilter::HotSpot* FileFilter::newHotSpot(int startLine, int startColumn, int endLine, int endColumn, const QStringList& capturedTexts) { - if (!_session) { + if (_session == nullptr) { qCDebug(KonsoleDebug) << "Trying to create new hot spot without session!"; return nullptr; } diff --git a/src/History.cpp b/src/History.cpp index 717b7e228..64b589ec2 100644 --- a/src/History.cpp +++ b/src/History.cpp @@ -91,7 +91,7 @@ HistoryFile::HistoryFile() HistoryFile::~HistoryFile() { - if (_fileMap) + if (_fileMap != nullptr) unmap(); } @@ -128,7 +128,7 @@ bool HistoryFile::isMapped() const void HistoryFile::add(const unsigned char* buffer, int count) { - if (_fileMap) + if (_fileMap != nullptr) unmap(); _readWriteBalance++; @@ -155,7 +155,7 @@ void HistoryFile::get(unsigned char* buffer, int size, int loc) //calls (decided by using MAP_THRESHOLD) then mmap the log //file to improve performance. _readWriteBalance--; - if (!_fileMap && _readWriteBalance < MAP_THRESHOLD) + if ((_fileMap == nullptr) && _readWriteBalance < MAP_THRESHOLD) map(); if (loc < 0 || size < 0 || loc + size > _length) { @@ -163,7 +163,7 @@ void HistoryFile::get(unsigned char* buffer, int size, int loc) return; } - if (_fileMap) { + if (_fileMap != nullptr) { for (int i = 0; i < size; i++) buffer[i] = _fileMap[loc + i]; } else { @@ -607,7 +607,7 @@ bool HistoryTypeFile::isEnabled() const HistoryScroll* HistoryTypeFile::scroll(HistoryScroll* old) const { - if (dynamic_cast(old)) + if (dynamic_cast(old) != nullptr) return old; // Unchanged. HistoryScroll* newScroll = new HistoryScrollFile(_fileName); @@ -657,9 +657,9 @@ int CompactHistoryType::maximumLineCount() const HistoryScroll* CompactHistoryType::scroll(HistoryScroll* old) const { - if (old) { + if (old != nullptr) { CompactHistoryScroll* oldBuffer = dynamic_cast(old); - if (oldBuffer) { + if (oldBuffer != nullptr) { oldBuffer->setMaxNbLines(_maxLines); return oldBuffer; } diff --git a/src/KeyBindingEditor.cpp b/src/KeyBindingEditor.cpp index e227e008e..618e37578 100644 --- a/src/KeyBindingEditor.cpp +++ b/src/KeyBindingEditor.cpp @@ -158,7 +158,7 @@ void KeyBindingEditor::setDescription(const QString& newDescription) void KeyBindingEditor::setTranslatorDescription(const QString& newDescription) { - if (_translator) + if (_translator != nullptr) _translator->setDescription(newDescription); } diff --git a/src/KeyboardTranslatorManager.cpp b/src/KeyboardTranslatorManager.cpp index 299150881..3c288126a 100644 --- a/src/KeyboardTranslatorManager.cpp +++ b/src/KeyboardTranslatorManager.cpp @@ -189,7 +189,7 @@ const KeyboardTranslator* KeyboardTranslatorManager::defaultTranslator() // Try to find the default.keytab file if it exists, otherwise // fall back to the internal hard-coded fallback translator const KeyboardTranslator* translator = findTranslator(QStringLiteral("default")); - if (!translator) { + if (translator == nullptr) { translator = _fallbackTranslator; } return translator; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 690b34dd4..b6d6abf0e 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -174,7 +174,7 @@ void MainWindow::correctStandardShortcuts() { // replace F1 shortcut for help contents QAction* helpAction = actionCollection()->action(QStringLiteral("help_contents")); - if (helpAction) { + if (helpAction != nullptr) { actionCollection()->setDefaultShortcut(helpAction, QKeySequence()); } @@ -182,7 +182,7 @@ void MainWindow::correctStandardShortcuts() // changed the shortcut; however, if the user changed it to Ctrl+B // this will still get changed to Ctrl+Shift+B QAction* bookmarkAction = actionCollection()->action(QStringLiteral("add_bookmark")); - if (bookmarkAction && bookmarkAction->shortcut() == QKeySequence(Konsole::ACCEL + Qt::Key_B)) { + if ((bookmarkAction != nullptr) && bookmarkAction->shortcut() == QKeySequence(Konsole::ACCEL + Qt::Key_B)) { actionCollection()->setDefaultShortcut(bookmarkAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_B); } } @@ -218,7 +218,7 @@ void MainWindow::activeViewChanged(SessionController* controller) disconnect(bookmarkHandler(), &Konsole::BookmarkHandler::openUrl, 0, 0); connect(bookmarkHandler(), &Konsole::BookmarkHandler::openUrl, controller, &Konsole::SessionController::openUrl); - if (_pluggedController) + if (_pluggedController != nullptr) disconnectController(_pluggedController); Q_ASSERT(controller); @@ -250,7 +250,7 @@ void MainWindow::activeViewTitleChanged(ViewProperties* properties) void MainWindow::updateWindowCaption() { - if (!_pluggedController) + if (_pluggedController == nullptr) return; const QString& title = _pluggedController->title(); @@ -273,7 +273,7 @@ void MainWindow::updateWindowCaption() void MainWindow::updateWindowIcon() { - if (_pluggedController && !_pluggedController->icon().isNull()) + if ((_pluggedController != nullptr) && !_pluggedController->icon().isNull()) setWindowIcon(_pluggedController->icon()); } @@ -374,7 +374,7 @@ void MainWindow::profileListChanged(const QList& sessionActions) // it if it is the non-default profile. if (sessionActions.size() > 2) { // Update the 'New Tab' KActionMenu - if (_newTabMenuAction->menu()) { + if (_newTabMenuAction->menu() != nullptr) { _newTabMenuAction->menu()->clear(); } else { _newTabMenuAction->setMenu(new QMenu()); @@ -394,7 +394,7 @@ void MainWindow::profileListChanged(const QList& sessionActions) } } } else { - if (_newTabMenuAction->menu()) { + if (_newTabMenuAction->menu() != nullptr) { _newTabMenuAction->menu()->clear(); } else { _newTabMenuAction->setMenu(new QMenu()); @@ -412,7 +412,7 @@ void MainWindow::profileListChanged(const QList& sessionActions) QString MainWindow::activeSessionDir() const { - if (_pluggedController) { + if (_pluggedController != nullptr) { if (Session* session = _pluggedController->session()) { // For new tabs to get the correct working directory, // force the updating of the currentWorkingDirectory. @@ -536,7 +536,7 @@ bool MainWindow::queryClose() // Check what processes are running, excluding the shell QStringList processesRunning; foreach(Session *session, _viewManager->sessions()) { - if (!session || !session->isForegroundProcessActive()) { + if ((session == nullptr) || !session->isForegroundProcessActive()) { continue; } @@ -600,7 +600,7 @@ bool MainWindow::queryClose() case KMessageBox::Yes: return true; case KMessageBox::No: - if (_pluggedController && _pluggedController->session()) { + if ((_pluggedController != nullptr) && (_pluggedController->session() != nullptr)) { disconnectController(_pluggedController); _pluggedController->session()->closeInNormalWay(); } @@ -654,7 +654,7 @@ void MainWindow::showShortcutsDialog() // sync shortcuts for non-session actions (defined in "konsoleui.rc") in other main windows foreach(QWidget* mainWindowWidget, QApplication::topLevelWidgets()) { MainWindow* mainWindow = qobject_cast(mainWindowWidget); - if (mainWindow && mainWindow != this) + if ((mainWindow != nullptr) && mainWindow != this) syncActiveShortcuts(mainWindow->actionCollection(), actionCollection()); } // sync shortcuts for session actions (defined in "sessionui.rc") in other session controllers. @@ -663,7 +663,7 @@ void MainWindow::showShortcutsDialog() // when they are plugged into a main window. foreach(SessionController * controller, SessionController::allControllers()) { controller->reloadXML(); - if (controller->factory() && controller != _pluggedController) + if ((controller->factory() != nullptr) && controller != _pluggedController) syncActiveShortcuts(controller->actionCollection(), _pluggedController->actionCollection()); } } diff --git a/src/Part.cpp b/src/Part.cpp index 2b68214e8..5b537ef21 100644 --- a/src/Part.cpp +++ b/src/Part.cpp @@ -98,7 +98,7 @@ void Part::newTab() Session* Part::activeSession() const { - if (_viewManager->activeViewController()) { + if (_viewManager->activeViewController() != nullptr) { Q_ASSERT(_viewManager->activeViewController()->session()); return _viewManager->activeViewController()->session(); @@ -215,7 +215,7 @@ void Part::activeViewChanged(SessionController* controller) Q_ASSERT(controller->view()); // remove existing controller - if (_pluggedController) { + if (_pluggedController != nullptr) { removeChildClient(_pluggedController); disconnect(_pluggedController, &Konsole::SessionController::titleChanged, this, &Konsole::Part::activeViewTitleChanged); diff --git a/src/ProcessInfo.cpp b/src/ProcessInfo.cpp index b0745df75..89bcbdac7 100644 --- a/src/ProcessInfo.cpp +++ b/src/ProcessInfo.cpp @@ -279,7 +279,7 @@ bool ProcessInfo::userNameRequired() const QString ProcessInfo::currentDir(bool* ok) const { - if (ok) + if (ok != nullptr) *ok = (_fields & CURRENT_DIR) != 0; return _currentDir; diff --git a/src/ProfileList.cpp b/src/ProfileList.cpp index 5aaafe171..51074e70a 100644 --- a/src/ProfileList.cpp +++ b/src/ProfileList.cpp @@ -83,7 +83,7 @@ QAction* ProfileList::actionForProfile(Profile::Ptr profile) const void ProfileList::profileChanged(Profile::Ptr profile) { QAction* action = actionForProfile(profile); - if (action) + if (action != nullptr) updateAction(action, profile); } @@ -102,7 +102,7 @@ void ProfileList::shortcutChanged(Profile::Ptr profile, const QKeySequence& sequ QAction* action = actionForProfile(profile); - if (action) { + if (action != nullptr) { action->setShortcut(sequence); } } @@ -143,7 +143,7 @@ void ProfileList::favoriteChanged(Profile::Ptr profile, bool isFavorite) } else { QAction* action = actionForProfile(profile); - if (action) { + if (action != nullptr) { _group->removeAction(action); foreach(QWidget * widget, _registeredWidgets) { widget->removeAction(action); diff --git a/src/Screen.cpp b/src/Screen.cpp index 3b4a07b5c..325d6e462 100644 --- a/src/Screen.cpp +++ b/src/Screen.cpp @@ -659,7 +659,7 @@ void Screen::displayCharacter(unsigned short c) ushort extendedCharLength; const ushort* oldChars = ExtendedCharTable::instance.lookupExtendedChar(currentChar.character, extendedCharLength); Q_ASSERT(oldChars); - if ((oldChars) && extendedCharLength < 3) { + if (((oldChars) != nullptr) && extendedCharLength < 3) { Q_ASSERT(extendedCharLength > 1); Q_ASSERT(extendedCharLength < 65535); auto chars = new ushort[extendedCharLength + 1]; diff --git a/src/Session.cpp b/src/Session.cpp index b8cf82a9d..0391f22da 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -193,7 +193,7 @@ void Session::setDarkBackground(bool darkBackground) bool Session::isRunning() const { - return _shellProcess && (_shellProcess->state() == QProcess::Running); + return (_shellProcess != nullptr) && (_shellProcess->state() == QProcess::Running); } void Session::setCodec(QTextCodec* codec) @@ -205,7 +205,7 @@ bool Session::setCodec(const QByteArray& name) { QTextCodec* codec = QTextCodec::codecForName(name); - if (codec) { + if (codec != nullptr) { setCodec(codec); return true; } else { @@ -975,7 +975,7 @@ void Session::updateSessionProcessInfo() // The checking for pid changing looks stupid, but it is needed // at the moment to workaround the problem that processId() might // return 0 - if (!_sessionProcessInfo || + if ((_sessionProcessInfo == nullptr) || (processId() != 0 && processId() != _sessionProcessInfo->pid(&ok))) { delete _sessionProcessInfo; _sessionProcessInfo = ProcessInfo::newInstance(processId(), @@ -997,7 +997,7 @@ bool Session::updateForegroundProcessInfo() _foregroundPid = foregroundPid; } - if (_foregroundProcessInfo) { + if (_foregroundProcessInfo != nullptr) { _foregroundProcessInfo->update(); return _foregroundProcessInfo->isValid(); } else { @@ -1228,14 +1228,14 @@ void Session::setFlowControlEnabled(bool enabled) { _flowControlEnabled = enabled; - if (_shellProcess) + if (_shellProcess != nullptr) _shellProcess->setFlowControlEnabled(_flowControlEnabled); emit flowControlEnabledChanged(enabled); } bool Session::flowControlEnabled() const { - if (_shellProcess) + if (_shellProcess != nullptr) return _shellProcess->flowControlEnabled(); else return _flowControlEnabled; @@ -1329,7 +1329,7 @@ void Session::zmodemFinished() ZModemDialog's user1Clicked(). Therefore, an invocation by user1Clicked() will recursively invoke this function again when the KProcess is deleted! */ - if (_zmodemProc) { + if (_zmodemProc != nullptr) { KProcess* process = _zmodemProc; _zmodemProc = 0; // Set _zmodemProc to 0 avoid recursive invocations! _zmodemBusy = false; diff --git a/src/SessionController.cpp b/src/SessionController.cpp index 09ba1edf8..7a1d11bf0 100644 --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -215,7 +215,7 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q SessionController::~SessionController() { - if (_view) + if (_view != nullptr) _view->setScreenWindow(0); _allControllers.remove(this); @@ -254,7 +254,7 @@ void SessionController::snapshot() title = title.simplified(); // Visualize that the session is broadcasting to others - if (_copyToGroup && _copyToGroup->sessions().count() > 1) { + if ((_copyToGroup != nullptr) && _copyToGroup->sessions().count() > 1) { title.append('*'); } @@ -421,7 +421,7 @@ void SessionController::updateWebSearchMenu() void SessionController::handleWebShortcutAction() { QAction * action = qobject_cast(sender()); - if (!action) + if (action == nullptr) return; KUriFilterData filterData(action->data().toString()); @@ -464,7 +464,7 @@ bool SessionController::eventFilter(QObject* watched , QEvent* event) // second, connect the newly focused view to listen for the session's bell signal connect(_session.data(), &Konsole::Session::bellRequest, _view.data(), &Konsole::TerminalDisplay::bell); - if (_copyInputToAllTabsAction && _copyInputToAllTabsAction->isChecked()) { + if ((_copyInputToAllTabsAction != nullptr) && _copyInputToAllTabsAction->isChecked()) { // A session with "Copy To All Tabs" has come into focus: // Ensure that newly created sessions are included in _copyToGroup! copyInputToAllTabs(); @@ -476,7 +476,7 @@ bool SessionController::eventFilter(QObject* watched , QEvent* event) void SessionController::removeSearchFilter() { - if (!_searchFilter) + if (_searchFilter == nullptr) return; _view->filterChain()->removeFilter(_searchFilter); @@ -487,14 +487,14 @@ void SessionController::removeSearchFilter() void SessionController::setSearchBar(IncrementalSearchBar* searchBar) { // disconnect the existing search bar - if (_searchBar) { + if (_searchBar != nullptr) { disconnect(this, 0, _searchBar, 0); disconnect(_searchBar, 0, this, 0); } // connect new search bar _searchBar = searchBar; - if (_searchBar) { + if (_searchBar != nullptr) { connect(_searchBar.data(), &Konsole::IncrementalSearchBar::unhandledMovementKeyPressed, this, &Konsole::SessionController::movementKeyFromSearchBarReceived); connect(_searchBar.data(), &Konsole::IncrementalSearchBar::closeClicked, this, &Konsole::SessionController::searchClosed); connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchFromClicked, this, &Konsole::SessionController::searchFrom); @@ -799,7 +799,7 @@ void SessionController::editCurrentProfile() // Searching for Edit profile dialog opened with the same profile const QList allSessionsControllers = _allControllers.values(); foreach (SessionController* session, allSessionsControllers) { - if (session->profileDialogPointer() + if ((session->profileDialogPointer() != nullptr) && session->profileDialogPointer()->isVisible() && session->profileDialogPointer()->lookupProfile() == SessionManager::instance()->sessionProfile(_session)) { session->profileDialogPointer()->close(); @@ -831,7 +831,7 @@ void SessionController::renameSession() QPointer guard(_session); int result = dialog->exec(); - if (!guard) + if (guard == nullptr) return; if (result != 0) { @@ -998,7 +998,7 @@ void SessionController::copyInputActionsTriggered(QAction* action) void SessionController::copyInputToAllTabs() { - if (!_copyToGroup) { + if (_copyToGroup == nullptr) { _copyToGroup = new SessionGroup(this); } @@ -1025,7 +1025,7 @@ void SessionController::copyInputToAllTabs() void SessionController::copyInputToSelectedTabs() { - if (!_copyToGroup) { + if (_copyToGroup == nullptr) { _copyToGroup = new SessionGroup(this); _copyToGroup->addSession(_session); _copyToGroup->setMasterStatus(_session, true); @@ -1042,7 +1042,7 @@ void SessionController::copyInputToSelectedTabs() QPointer guard(_session); int result = dialog->exec(); - if (!guard) + if (guard == nullptr) return; if (result == QDialog::Accepted) { @@ -1065,7 +1065,7 @@ void SessionController::copyInputToSelectedTabs() void SessionController::copyInputToNone() { - if (!_copyToGroup) // No 'Copy To' is active + if (_copyToGroup == nullptr) // No 'Copy To' is active return; QSet group = @@ -1096,21 +1096,21 @@ void SessionController::updateFilterList(Profile::Ptr profile) bool underlineFiles = profile->underlineFilesEnabled(); - if (!underlineFiles && _fileFilter) { + if (!underlineFiles && (_fileFilter != nullptr)) { _view->filterChain()->removeFilter(_fileFilter); delete _fileFilter; _fileFilter = nullptr; - } else if (underlineFiles && !_fileFilter) { + } else if (underlineFiles && (_fileFilter == nullptr)) { _fileFilter = new FileFilter(_session); _view->filterChain()->addFilter(_fileFilter); } bool underlineLinks = profile->underlineLinksEnabled(); - if (!underlineLinks && _urlFilter) { + if (!underlineLinks && (_urlFilter != nullptr)) { _view->filterChain()->removeFilter(_urlFilter); delete _urlFilter; _urlFilter = nullptr; - } else if (underlineLinks && !_urlFilter) { + } else if (underlineLinks && (_urlFilter == nullptr)) { _urlFilter = new UrlFilter(); _view->filterChain()->addFilter(_urlFilter); } @@ -1141,7 +1141,7 @@ void SessionController::listenForScreenWindowUpdates() void SessionController::updateSearchFilter() { - if (_searchFilter && _searchBar) { + if ((_searchFilter != nullptr) && (_searchBar != nullptr)) { _view->processFilters(); } } @@ -1162,7 +1162,7 @@ void SessionController::searchBarEvent() void SessionController::enableSearchBar(bool showSearchBar) { - if (!_searchBar) + if (_searchBar == nullptr) return; if (showSearchBar && !_searchBar->isVisible()) { @@ -1181,7 +1181,7 @@ void SessionController::enableSearchBar(bool showSearchBar) &Konsole::SessionController::findPreviousInHistory); disconnect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this, &Konsole::SessionController::findNextInHistory); - if (_view && _view->screenWindow()) { + if ((_view != nullptr) && (_view->screenWindow() != nullptr)) { _view->screenWindow()->setCurrentResultLine(-1); } } @@ -1222,7 +1222,7 @@ void SessionController::searchHistory(bool showSearchBar) { enableSearchBar(showSearchBar); - if (_searchBar) { + if (_searchBar != nullptr) { if (showSearchBar) { removeSearchFilter(); @@ -1271,7 +1271,7 @@ void SessionController::searchCompleted(bool success) { _prevSearchResultLine = _view->screenWindow()->currentResultLine(); - if (_searchBar) + if (_searchBar != nullptr) _searchBar->setFoundMatch(success); } @@ -1380,7 +1380,7 @@ void SessionController::showHistoryOptions() QPointer guard(_session); int result = dialog->exec(); - if (!guard) + if (guard == nullptr) return; if (result != 0) { @@ -1481,7 +1481,7 @@ void SessionController::monitorSilence(bool monitor) void SessionController::updateSessionIcon() { // Visualize that the session is broadcasting to others - if (_copyToGroup && _copyToGroup->sessions().count() > 1) { + if ((_copyToGroup != nullptr) && _copyToGroup->sessions().count() > 1) { // Master Mode: set different icon, to warn the user to be careful setIcon(*_broadcastIcon); } else { @@ -1519,8 +1519,8 @@ void SessionController::showDisplayContextMenu(const QPoint& position) { // needed to make sure the popup menu is available, even if a hosting // application did not merge our GUI. - if (!factory()) { - if (!clientBuilder()) { + if (factory() == nullptr) { + if (clientBuilder() == nullptr) { setClientBuilder(new KXMLGUIBuilder(_view)); } @@ -1530,7 +1530,7 @@ void SessionController::showDisplayContextMenu(const QPoint& position) } QPointer popup = qobject_cast(factory()->container("session-popup-menu", this)); - if (popup) { + if (popup != nullptr) { // prepend content-specific actions such as "Open Link", "Copy Email Address" etc. QList contentActions = _view->filterActions(position); auto contentSeparator = new QAction(popup); @@ -1545,7 +1545,7 @@ void SessionController::showDisplayContextMenu(const QPoint& position) _preventClose = true; - if (_showMenuAction) { + if (_showMenuAction != nullptr) { if ( _showMenuAction->isChecked() ) { popup->removeAction( _showMenuAction); } else { @@ -1556,7 +1556,7 @@ void SessionController::showDisplayContextMenu(const QPoint& position) QAction* chosen = popup->exec(_view->mapToGlobal(position)); // check for validity of the pointer to the popup menu - if (popup) { + if (popup != nullptr) { // Remove content-specific actions // // If the close action was chosen, the popup menu will be partially @@ -1571,7 +1571,7 @@ void SessionController::showDisplayContextMenu(const QPoint& position) _preventClose = false; - if (chosen && chosen->objectName() == "close-session") + if ((chosen != nullptr) && chosen->objectName() == "close-session") chosen->trigger(); } else { qCDebug(KonsoleDebug) << "Unable to display popup menu for session" @@ -1778,7 +1778,7 @@ void SaveHistoryTask::jobDataRequested(KIO::Job* job , QByteArray& data) // transfer LINES_PER_REQUEST lines from the session's history // to the save location - if (info.session) { + if (info.session != nullptr) { // note: when retrieving lines from the emulation, // the first line is at index 0. @@ -2000,7 +2000,7 @@ QRegularExpression SearchHistoryTask::regExp() const QString SessionController::userTitle() const { - if (_session) { + if (_session != nullptr) { return _session->userTitle(); } else { return QString(); diff --git a/src/TerminalCharacterDecoder.cpp b/src/TerminalCharacterDecoder.cpp index 5f9966a45..31f444c82 100644 --- a/src/TerminalCharacterDecoder.cpp +++ b/src/TerminalCharacterDecoder.cpp @@ -69,7 +69,7 @@ void PlainTextDecoder::decodeLine(const Character* const characters, int count, { Q_ASSERT(_output); - if (_recordLinePositions && _output->string()) { + if (_recordLinePositions && (_output->string() != nullptr)) { int pos = _output->string()->count(); _linePositions << pos; } @@ -111,7 +111,7 @@ void PlainTextDecoder::decodeLine(const Character* const characters, int count, if ((characters[i].rendition & RE_EXTENDED_CHAR) != 0) { ushort extendedCharLength = 0; const ushort* chars = ExtendedCharTable::instance.lookupExtendedChar(characters[i].character, extendedCharLength); - if (chars) { + if (chars != nullptr) { const QString s = QString::fromUtf16(chars, extendedCharLength); plainText.append(s); i += qMax(1, string_width(s)); @@ -198,7 +198,7 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP QString style; //colors - a color table must have been defined first - if (_colorTable) { + if (_colorTable != nullptr) { bool useBold = (_lastRendition & RE_BOLD) != 0; if (useBold) style.append("font-weight:bold;"); @@ -227,7 +227,7 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP if ((characters[i].rendition & RE_EXTENDED_CHAR) != 0) { ushort extendedCharLength = 0; const ushort* chars = ExtendedCharTable::instance.lookupExtendedChar(characters[i].character, extendedCharLength); - if (chars) { + if (chars != nullptr) { text.append(QString::fromUtf16(chars, extendedCharLength)); } } else { diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index fb95652d2..64f73426b 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -106,13 +106,13 @@ ScreenWindow* TerminalDisplay::screenWindow() const void TerminalDisplay::setScreenWindow(ScreenWindow* window) { // disconnect existing screen window if any - if (_screenWindow) { + if (_screenWindow != nullptr) { disconnect(_screenWindow , 0 , this , 0); } _screenWindow = window; - if (_screenWindow) { + if (_screenWindow != nullptr) { connect(_screenWindow.data() , &Konsole::ScreenWindow::outputChanged , this , &Konsole::TerminalDisplay::updateLineProperties); connect(_screenWindow.data() , &Konsole::ScreenWindow::outputChanged , this , &Konsole::TerminalDisplay::updateImage); connect(_screenWindow.data() , &Konsole::ScreenWindow::currentResultLineChanged , this , &Konsole::TerminalDisplay::updateImage); @@ -931,7 +931,7 @@ void TerminalDisplay::scrollImage(int lines , const QRect& screenWindowRegion) // if the flow control warning is enabled this will interfere with the // scrolling optimizations and cause artifacts. the simple solution here // is to just disable the optimization whilst it is visible - if (_outputSuspendedLabel && _outputSuspendedLabel->isVisible()) + if ((_outputSuspendedLabel != nullptr) && _outputSuspendedLabel->isVisible()) return; // constrain the region to the display @@ -949,7 +949,7 @@ void TerminalDisplay::scrollImage(int lines , const QRect& screenWindowRegion) || this->_lines <= region.height()) return; // hide terminal size label to prevent it being scrolled - if (_resizeWidget && _resizeWidget->isVisible()) + if ((_resizeWidget != nullptr) && _resizeWidget->isVisible()) _resizeWidget->hide(); // Note: With Qt 4.4 the left edge of the scrolled area must be at 0 @@ -1050,7 +1050,7 @@ QRegion TerminalDisplay::hotSpotRegion() const void TerminalDisplay::processFilters() { - if (!_screenWindow) { + if (_screenWindow == nullptr) { return; } @@ -1079,7 +1079,7 @@ void TerminalDisplay::processFilters() void TerminalDisplay::updateImage() { - if (!_screenWindow) + if (_screenWindow == nullptr) return; // optimization - scroll the existing image where possible and @@ -1092,7 +1092,7 @@ void TerminalDisplay::updateImage() _screenWindow->resetScrollCount(); } - if (!_image) { + if (_image == nullptr) { // Create _image. // The emitted changedContentSizeSignal also leads to getImage being recreated, so do this first. updateImageSize(); @@ -1260,7 +1260,7 @@ void TerminalDisplay::updateImage() void TerminalDisplay::showResizeNotification() { if (_showTerminalSizeHint && isVisible()) { - if (!_resizeWidget) { + if (_resizeWidget == nullptr) { _resizeWidget = new QLabel(i18n("Size: XXX x XXX"), this); _resizeWidget->setMinimumWidth(_resizeWidget->fontMetrics().width(i18n("Size: XXX x XXX"))); _resizeWidget->setMinimumHeight(_resizeWidget->sizeHint().height()); @@ -1319,7 +1319,7 @@ void TerminalDisplay::printContent(QPainter& painter, bool friendly) QPoint TerminalDisplay::cursorPosition() const { - if (_screenWindow) + if (_screenWindow != nullptr) return _screenWindow->cursorPosition(); else return QPoint(0, 0); @@ -1491,7 +1491,7 @@ void TerminalDisplay::drawContents(QPainter& paint, const QRect& rect) // sequence of characters ushort extendedCharLength = 0; const ushort* chars = ExtendedCharTable::instance.lookupExtendedChar(_image[loc(x, y)].character, extendedCharLength); - if (chars) { + if (chars != nullptr) { Q_ASSERT(extendedCharLength > 1); bufferSize += extendedCharLength - 1; unistr.resize(bufferSize); @@ -1527,7 +1527,7 @@ void TerminalDisplay::drawContents(QPainter& paint, const QRect& rect) // sequence of characters ushort extendedCharLength = 0; const ushort* chars = ExtendedCharTable::instance.lookupExtendedChar(c, extendedCharLength); - if (chars) { + if (chars != nullptr) { Q_ASSERT(extendedCharLength > 1); bufferSize += extendedCharLength - 1; unistr.resize(bufferSize); @@ -1755,7 +1755,7 @@ void TerminalDisplay::resizeEvent(QResizeEvent*) void TerminalDisplay::propagateSize() { - if (_image) + if (_image != nullptr) updateImageSize(); } @@ -1767,7 +1767,7 @@ void TerminalDisplay::updateImageSize() makeImage(); - if (oldImage) { + if (oldImage != nullptr) { // copy the old image to reduce flicker int lines = qMin(oldLines, _lines); int columns = qMin(oldColumns, _columns); @@ -1779,7 +1779,7 @@ void TerminalDisplay::updateImageSize() delete[] oldImage; } - if (_screenWindow) + if (_screenWindow != nullptr) _screenWindow->setWindowLines(_lines); _resizing = (oldLines != _lines) || (oldColumns != _columns); @@ -1925,7 +1925,7 @@ void TerminalDisplay::setScrollBarPosition(Enum::ScrollBarPositionEnum position) void TerminalDisplay::scrollBarPositionChanged(int) { - if (!_screenWindow) + if (_screenWindow == nullptr) return; _screenWindow->scrollTo(_scrollBar->value()); @@ -1985,7 +1985,7 @@ void TerminalDisplay::mousePressEvent(QMouseEvent* ev) if (!contentsRect().contains(ev->pos())) return; - if (!_screenWindow) return; + if (_screenWindow == nullptr) return; int charLine; int charColumn; @@ -2037,7 +2037,7 @@ void TerminalDisplay::mousePressEvent(QMouseEvent* ev) if ((_openLinksByDirectClick || ((ev->modifiers() & Qt::ControlModifier) != 0u))) { Filter::HotSpot* spot = _filterChain->hotSpotAt(charLine, charColumn); - if (spot && spot->type() == Filter::HotSpot::Link) { + if ((spot != nullptr) && spot->type() == Filter::HotSpot::Link) { QObject action; action.setObjectName("open-action"); spot->activate(&action); @@ -2061,7 +2061,7 @@ QList TerminalDisplay::filterActions(const QPoint& position) Filter::HotSpot* spot = _filterChain->hotSpotAt(charLine, charColumn); - return spot ? spot->actions() : QList(); + return spot != nullptr ? spot->actions() : QList(); } void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev) @@ -2074,7 +2074,7 @@ void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev) // handle filters // change link hot-spot appearance on mouse-over Filter::HotSpot* spot = _filterChain->hotSpotAt(charLine, charColumn); - if (spot && spot->type() == Filter::HotSpot::Link) { + if ((spot != nullptr) && spot->type() == Filter::HotSpot::Link) { QRegion previousHotspotArea = _mouseOverHotspotArea; _mouseOverHotspotArea = QRegion(); QRect r; @@ -2178,7 +2178,7 @@ void TerminalDisplay::leaveEvent(QEvent *) void TerminalDisplay::extendSelection(const QPoint& position) { - if (!_screenWindow) + if (_screenWindow == nullptr) return; //if ( !contentsRect().contains(ev->pos()) ) return; @@ -2331,7 +2331,7 @@ void TerminalDisplay::extendSelection(const QPoint& position) void TerminalDisplay::mouseReleaseEvent(QMouseEvent* ev) { - if (!_screenWindow) + if (_screenWindow == nullptr) return; int charLine; @@ -2395,7 +2395,7 @@ void TerminalDisplay::getCharacterPosition(const QPoint& widgetPoint, int& line, void TerminalDisplay::updateLineProperties() { - if (!_screenWindow) + if (_screenWindow == nullptr) return; _lineProperties = _screenWindow->getLineProperties(); @@ -2431,7 +2431,7 @@ void TerminalDisplay::mouseDoubleClickEvent(QMouseEvent* ev) } if (ev->button() != Qt::LeftButton) return; - if (!_screenWindow) return; + if (_screenWindow == nullptr) return; int charLine = 0; int charColumn = 0; @@ -2645,7 +2645,7 @@ QPoint TerminalDisplay::findWordStart(const QPoint &pnt) int newRegStart = qMax(0, y - regSize); lineProperties = screen->getLineProperties(newRegStart, y - 1); i = y - newRegStart; - if (!tmp_image) { + if (tmp_image == nullptr) { tmp_image = new Character[imageSize]; image = tmp_image; } @@ -2653,7 +2653,7 @@ QPoint TerminalDisplay::findWordStart(const QPoint &pnt) j = loc(x, i); } out: - if (tmp_image) { + if (tmp_image != nullptr) { delete[] tmp_image; } return QPoint(x, y - curLine); @@ -2703,7 +2703,7 @@ QPoint TerminalDisplay::findWordEnd(const QPoint &pnt) int newRegEnd = qMin(y + regSize - 1, maxY); lineProperties = screen->getLineProperties(y, newRegEnd); i = 0; - if (!tmp_image) { + if (tmp_image == nullptr) { tmp_image = new Character[imageSize]; image = tmp_image; } @@ -2723,7 +2723,7 @@ out: y--; } } - if (tmp_image) { + if (tmp_image != nullptr) { delete[] tmp_image; } return QPoint(x, y); @@ -2731,7 +2731,7 @@ out: void TerminalDisplay::mouseTripleClickEvent(QMouseEvent* ev) { - if (!_screenWindow) return; + if (_screenWindow == nullptr) return; int charLine; int charColumn; @@ -2770,7 +2770,7 @@ void TerminalDisplay::selectLine(QPoint pos, bool entireLine) void TerminalDisplay::selectCurrentLine() { - if (!_screenWindow) return; + if (_screenWindow == nullptr) return; selectLine(cursorPosition(), true); } @@ -2790,7 +2790,7 @@ QChar TerminalDisplay::charClass(const Character& ch) const if ((ch.rendition & RE_EXTENDED_CHAR) != 0) { ushort extendedCharLength = 0; const ushort* chars = ExtendedCharTable::instance.lookupExtendedChar(ch.character, extendedCharLength); - if (chars && extendedCharLength > 0) { + if ((chars != nullptr) && extendedCharLength > 0) { const QString s = QString::fromUtf16(chars, extendedCharLength); if (_wordCharacters.contains(s, Qt::CaseInsensitive)) return 'a'; @@ -2847,7 +2847,7 @@ bool TerminalDisplay::bracketedPasteMode() const void TerminalDisplay::doPaste(QString text, bool appendReturn) { - if (!_screenWindow) + if (_screenWindow == nullptr) return; if (appendReturn) @@ -2889,7 +2889,7 @@ void TerminalDisplay::setMiddleClickPasteMode(Enum::MiddleClickPasteModeEnum mod void TerminalDisplay::copyToX11Selection() { - if (!_screenWindow) + if (_screenWindow == nullptr) return; QString text = _screenWindow->selectedText(_preserveLineBreaks, _trimTrailingSpaces); @@ -2911,7 +2911,7 @@ void TerminalDisplay::copyToX11Selection() void TerminalDisplay::copyToClipboard() { - if (!_screenWindow) + if (_screenWindow == nullptr) return; QString text = _screenWindow->selectedText(_preserveLineBreaks, _trimTrailingSpaces); @@ -3040,7 +3040,7 @@ void TerminalDisplay::setFlowControlWarningEnabled(bool enable) void TerminalDisplay::outputSuspended(bool suspended) { //create the label when this function is first called - if (!_outputSuspendedLabel) { + if (_outputSuspendedLabel == nullptr) { //This label includes a link to an English language website //describing the 'flow control' (Xon/Xoff) feature found in almost //all terminal emulators. @@ -3341,7 +3341,7 @@ void TerminalDisplay::dropEvent(QDropEvent* event) // If our target is local we will open a popup - otherwise the fallback kicks // in and the URLs will simply be pasted as text. - if (!_dropUrlsAsText && _sessionController && _sessionController->url().isLocalFile()) { + if (!_dropUrlsAsText && (_sessionController != nullptr) && _sessionController->url().isLocalFile()) { // A standard popup with Copy, Move and Link as options - // plus an additional Paste option. @@ -3392,9 +3392,9 @@ void TerminalDisplay::dropEvent(QDropEvent* event) void TerminalDisplay::dropMenuPasteActionTriggered() { - if (sender()) { + if (sender() != nullptr) { const QAction* action = qobject_cast(sender()); - if (action) { + if (action != nullptr) { emit sendStringToEmu(action->data().toString().toLocal8Bit()); } } @@ -3402,9 +3402,9 @@ void TerminalDisplay::dropMenuPasteActionTriggered() void TerminalDisplay::dropMenuCdActionTriggered() { - if (sender()) { + if (sender() != nullptr) { const QAction* action = qobject_cast(sender()); - if (action) { + if (action != nullptr) { emit sendStringToEmu(action->data().toString().toLocal8Bit()); } } diff --git a/src/TerminalDisplayAccessible.cpp b/src/TerminalDisplayAccessible.cpp index 6003a92b7..fd1258eaa 100644 --- a/src/TerminalDisplayAccessible.cpp +++ b/src/TerminalDisplayAccessible.cpp @@ -45,7 +45,7 @@ int TerminalDisplayAccessible::characterCount() const int TerminalDisplayAccessible::cursorPosition() const { - if (!display()->screenWindow()) + if (display()->screenWindow() == nullptr) return 0; int offset = display()->_usedColumns * display()->screenWindow()->screen()->getCursorY(); @@ -56,7 +56,7 @@ void TerminalDisplayAccessible::selection(int selectionIndex, int* startOffset, { *startOffset = 0; *endOffset = 0; - if (!display()->screenWindow() || selectionIndex) + if ((display()->screenWindow() == nullptr) || (selectionIndex != 0)) return; int startLine; @@ -73,7 +73,7 @@ void TerminalDisplayAccessible::selection(int selectionIndex, int* startOffset, int TerminalDisplayAccessible::selectionCount() const { - if (!display()->screenWindow()) + if (display()->screenWindow() == nullptr) return 0; int startLine; @@ -89,7 +89,7 @@ QString TerminalDisplayAccessible::visibleText() const { // This function should be const to allow calling it from const interface functions. TerminalDisplay* display = const_cast(this)->display(); - if (!display->screenWindow()) + if (display->screenWindow() == nullptr) return QString(); return display->screenWindow()->screen()->text(0, display->_usedColumns * display->_usedLines, true); @@ -97,7 +97,7 @@ QString TerminalDisplayAccessible::visibleText() const void TerminalDisplayAccessible::addSelection(int startOffset, int endOffset) { - if (!display()->screenWindow()) + if (display()->screenWindow() == nullptr) return; display()->screenWindow()->setSelectionStart(columnForOffset(startOffset), lineForOffset(startOffset), false); display()->screenWindow()->setSelectionEnd(columnForOffset(endOffset), lineForOffset(endOffset)); @@ -130,7 +130,7 @@ int TerminalDisplayAccessible::offsetAtPoint(const QPoint& point) const void TerminalDisplayAccessible::removeSelection(int selectionIndex) { - if (!display()->screenWindow() || selectionIndex) + if ((display()->screenWindow() == nullptr) || (selectionIndex != 0)) return; display()->screenWindow()->clearSelection(); } @@ -144,7 +144,7 @@ void TerminalDisplayAccessible::scrollToSubstring(int startIndex, int endIndex) void TerminalDisplayAccessible::setCursorPosition(int position) { - if (!display()->screenWindow()) + if (display()->screenWindow() == nullptr) return; display()->screenWindow()->screen()->setCursorYX(lineForOffset(position), columnForOffset(position)); @@ -168,7 +168,7 @@ void TerminalDisplayAccessible::setSelection(int selectionIndex, int startOffset QString TerminalDisplayAccessible::text(int startOffset, int endOffset) const { - if (!display()->screenWindow()) { + if (display()->screenWindow() == nullptr) { return QString(); } diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp index 2b5361677..b5532be06 100644 --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -64,7 +64,7 @@ ViewContainer::~ViewContainer() disconnect(view, &QWidget::destroyed, this, &Konsole::ViewContainer::viewDestroyed); } - if (_searchBar) { + if (_searchBar != nullptr) { _searchBar->deleteLater(); } @@ -180,7 +180,7 @@ const QList ViewContainer::views() const IncrementalSearchBar* ViewContainer::searchBar() { - if (!_searchBar) { + if (_searchBar == nullptr) { _searchBar = new IncrementalSearchBar(0); _searchBar->setVisible(false); connect(_searchBar, &Konsole::IncrementalSearchBar::destroyed, this, &Konsole::ViewContainer::searchBarDestroyed); @@ -463,7 +463,7 @@ void TabbedViewContainer::startTabDrag(int tab) // start dragging const Qt::DropAction action = drag->exec(); - if (drag && drag->target()) { + if ((drag != nullptr) && (drag->target() != nullptr)) { switch (action) { case Qt::MoveAction: // The MoveAction indicates the widget has been successfully @@ -595,7 +595,7 @@ void TabbedViewContainer::moveViewWidget(int fromIndex , int toIndex) void TabbedViewContainer::currentTabChanged(int index) { _stackWidget->setCurrentIndex(index); - if (_stackWidget->widget(index)) + if (_stackWidget->widget(index) != nullptr) emit activeViewChanged(_stackWidget->widget(index)); // clear activity indicators @@ -645,7 +645,7 @@ void TabbedViewContainer::addViewWidget(QWidget* view , int index) void TabbedViewContainer::removeViewWidget(QWidget* view) { - if (!_stackWidget) + if (_stackWidget == nullptr) return; _stackWidget->removeWidget(view); } @@ -748,7 +748,7 @@ void StackedViewContainer::addViewWidget(QWidget* view , int) } void StackedViewContainer::removeViewWidget(QWidget* view) { - if (!_stackWidget) + if (_stackWidget == nullptr) return; _stackWidget->removeWidget(view); } diff --git a/src/ViewContainerTabBar.cpp b/src/ViewContainerTabBar.cpp index 699aab655..bd3cc1f64 100644 --- a/src/ViewContainerTabBar.cpp +++ b/src/ViewContainerTabBar.cpp @@ -159,15 +159,15 @@ TabbedViewContainer* ViewContainerTabBar::connectedTabbedViewContainer() void ViewContainerTabBar::setDropIndicator(int index, bool drawDisabled) { - if (!parentWidget() || _dropIndicatorIndex == index) + if ((parentWidget() == nullptr) || _dropIndicatorIndex == index) return; _dropIndicatorIndex = index; const int ARROW_SIZE = 32; const bool north = shape() == QTabBar::RoundedNorth || shape() == QTabBar::TriangularNorth; - if (!_dropIndicator || _drawIndicatorDisabled != drawDisabled) { - if (!_dropIndicator) { + if ((_dropIndicator == nullptr) || _drawIndicatorDisabled != drawDisabled) { + if (_dropIndicator == nullptr) { _dropIndicator = new QLabel(parentWidget()); _dropIndicator->resize(ARROW_SIZE, ARROW_SIZE); } diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 7f668f3ab..27fe6c9aa 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -108,7 +108,7 @@ int ViewManager::managerId() const QWidget* ViewManager::activeView() const { ViewContainer* container = _viewSplitter->activeContainer(); - if (container) { + if (container != nullptr) { return container->activeView(); } else { return 0; @@ -123,7 +123,7 @@ QWidget* ViewManager::widget() const void ViewManager::setupActions() { Q_ASSERT(_actionCollection); - if (!_actionCollection) { + if (_actionCollection == nullptr) { return; } @@ -269,16 +269,16 @@ void ViewManager::switchToView(int index) void ViewManager::updateDetachViewState() { Q_ASSERT(_actionCollection); - if (!_actionCollection) + if (_actionCollection == nullptr) return; const bool splitView = _viewSplitter->containers().count() >= 2; auto activeContainer = _viewSplitter->activeContainer(); - const bool shouldEnable = splitView || (activeContainer && activeContainer->views().count() >= 2); + const bool shouldEnable = splitView || ((activeContainer != nullptr) && activeContainer->views().count() >= 2); QAction* detachAction = _actionCollection->action("detach-view"); - if (detachAction && shouldEnable != detachAction->isEnabled()) + if ((detachAction != nullptr) && shouldEnable != detachAction->isEnabled()) detachAction->setEnabled(shouldEnable); } void ViewManager::moveActiveViewLeft() @@ -341,7 +341,7 @@ void ViewManager::detachView(ViewContainer* container, QWidget* widgetView) TerminalDisplay * viewToDetach = qobject_cast(widgetView); - if (!viewToDetach) + if (viewToDetach == nullptr) return; emit viewDetached(_sessionMap[viewToDetach]); @@ -365,7 +365,7 @@ void ViewManager::sessionFinished() { // if this slot is called after the view manager's main widget // has been destroyed, do nothing - if (!_viewSplitter) + if (_viewSplitter == nullptr) return; Session* session = qobject_cast(sender()); @@ -383,7 +383,7 @@ void ViewManager::sessionFinished() // This is needed to remove this controller from factory() in // order to prevent BUG: 185466 - disappearing menu popup - if (_pluggedController) + if (_pluggedController != nullptr) emit unplugController(_pluggedController); } @@ -433,9 +433,9 @@ void ViewManager::splitView(Qt::Orientation orientation) // ensure that the active view is focused after the split / unsplit ViewContainer* activeContainer = _viewSplitter->activeContainer(); - QWidget* activeView = activeContainer ? activeContainer->activeView() : 0; + QWidget* activeView = activeContainer != nullptr ? activeContainer->activeView() : 0; - if (activeView) + if (activeView != nullptr) activeView->setFocus(Qt::OtherFocusReason); } void ViewManager::removeContainer(ViewContainer* container) @@ -495,7 +495,7 @@ SessionController* ViewManager::createController(Session* session , TerminalDisp connect(view , &Konsole::TerminalDisplay::destroyed , controller , &Konsole::SessionController::deleteLater); // if this is the first controller created then set it as the active controller - if (!_pluggedController) + if (_pluggedController == nullptr) controllerChanged(controller); return controller; @@ -580,7 +580,7 @@ void ViewManager::createView(Session* session) if (_newTabBehavior == PutNewTabAfterCurrentTab) { QWidget* view = activeView(); - if (view) { + if (view != nullptr) { QList views = _viewSplitter->activeContainer()->views(); index = views.indexOf(view) + 1; } @@ -645,11 +645,11 @@ void ViewManager::containerMoveViewRequest(int index, int id, bool& moved, Tabbe ViewContainer* container = qobject_cast(sender()); SessionController* controller = qobject_cast(ViewProperties::propertiesById(id)); - if (!controller) + if (controller == nullptr) return; // do not move the last tab in a split view. - if (sourceTabbedContainer) { + if (sourceTabbedContainer != nullptr) { QPointer sourceContainer = qobject_cast(sourceTabbedContainer); if (_viewSplitter->containers().contains(sourceContainer)) { @@ -672,7 +672,7 @@ void ViewManager::containerMoveViewRequest(int index, int id, bool& moved, Tabbe void ViewManager::setNavigationMethod(NavigationMethod method) { Q_ASSERT(_actionCollection); - if (!_actionCollection) { + if (_actionCollection == nullptr) { return; } _navigationMethod = method; @@ -692,28 +692,28 @@ void ViewManager::setNavigationMethod(NavigationMethod method) QAction* action; action = collection->action("next-view"); - if (action) action->setEnabled(enable); + if (action != nullptr) action->setEnabled(enable); action = collection->action("previous-view"); - if (action) action->setEnabled(enable); + if (action != nullptr) action->setEnabled(enable); action = collection->action("last-tab"); - if (action) action->setEnabled(enable); + if (action != nullptr) action->setEnabled(enable); action = collection->action("split-view-left-right"); - if (action) action->setEnabled(enable); + if (action != nullptr) action->setEnabled(enable); action = collection->action("split-view-top-bottom"); - if (action) action->setEnabled(enable); + if (action != nullptr) action->setEnabled(enable); action = collection->action("rename-session"); - if (action) action->setEnabled(enable); + if (action != nullptr) action->setEnabled(enable); action = collection->action("move-view-left"); - if (action) action->setEnabled(enable); + if (action != nullptr) action->setEnabled(enable); action = collection->action("move-view-right"); - if (action) action->setEnabled(enable); + if (action != nullptr) action->setEnabled(enable); } ViewManager::NavigationMethod ViewManager::navigationMethod() const @@ -723,7 +723,7 @@ ViewManager::NavigationMethod ViewManager::navigationMethod() const void ViewManager::containerViewsChanged(QObject* container) { - if (_viewSplitter && container == _viewSplitter->activeContainer()) { + if ((_viewSplitter != nullptr) && container == _viewSplitter->activeContainer()) { emit viewPropertiesChanged(viewProperties()); } } @@ -739,12 +739,12 @@ void ViewManager::viewDestroyed(QWidget* view) // 2. if the session has no views left, close it Session* session = _sessionMap[ display ]; _sessionMap.remove(display); - if (session) { + if (session != nullptr) { if (session->views().count() == 0) session->close(); } //we only update the focus if the splitter is still alive - if (_viewSplitter) { + if (_viewSplitter != nullptr) { updateDetachViewState(); } // The below causes the menus to be messed up @@ -765,7 +765,7 @@ const ColorScheme* ViewManager::colorSchemeForProfile(const Profile::Ptr profile { const ColorScheme* colorScheme = ColorSchemeManager::instance()-> findColorScheme(profile->colorScheme()); - if (!colorScheme) + if (colorScheme == nullptr) colorScheme = ColorSchemeManager::instance()->defaultColorScheme(); Q_ASSERT(colorScheme); @@ -956,7 +956,7 @@ void ViewManager::restoreSessions(const KConfigGroup& group) foreach(int id, ids) { Session* session = SessionManager::instance()->idToSession(id); - if (!session) { + if (session == nullptr) { qWarning() << "Unable to load session with id" << id; // Force a creation of a default session below ids.clear(); @@ -970,7 +970,7 @@ void ViewManager::restoreSessions(const KConfigGroup& group) display = qobject_cast(activeView()); } - if (display) { + if (display != nullptr) { _viewSplitter->activeContainer()->setActiveView(display); display->setFocus(Qt::OtherFocusReason); } @@ -1071,7 +1071,7 @@ void ViewManager::closeTabFromContainer(ViewContainer* container, QWidget* tab) { SessionController* controller = qobject_cast(container->viewProperties(tab)); Q_ASSERT(controller); - if (controller) + if (controller != nullptr) controller->closeSession(); } diff --git a/src/ViewSplitter.cpp b/src/ViewSplitter.cpp index e1d8c6d67..d9695d0ef 100644 --- a/src/ViewSplitter.cpp +++ b/src/ViewSplitter.cpp @@ -69,11 +69,11 @@ void ViewSplitter::adjustContainerSize(ViewContainer* container , int percentage ViewSplitter* ViewSplitter::activeSplitter() { - QWidget* widget = focusWidget() ? focusWidget() : this; + QWidget* widget = focusWidget() != nullptr ? focusWidget() : this; ViewSplitter* splitter = 0; - while (!splitter && widget) { + while ((splitter == nullptr) && (widget != nullptr)) { splitter = qobject_cast(widget); widget = widget->parentWidget(); } @@ -227,7 +227,7 @@ void ViewSplitter::setActiveContainer(ViewContainer* container) { QWidget* activeView = container->activeView(); - if (activeView) + if (activeView != nullptr) activeView->setFocus(Qt::OtherFocusReason); } @@ -246,7 +246,7 @@ ViewContainer* ViewSplitter::activeContainer() const focusW = focusW->parentWidget(); } - if (focusContainer) + if (focusContainer != nullptr) return focusContainer; } diff --git a/src/Vt102Emulation.cpp b/src/Vt102Emulation.cpp index 197ed54e6..22314e199 100644 --- a/src/Vt102Emulation.cpp +++ b/src/Vt102Emulation.cpp @@ -96,7 +96,7 @@ void Vt102Emulation::reset() resetCharset(1); _screen[1]->reset(); - if (currentCodec) + if (currentCodec != nullptr) setCodec(currentCodec); else setCodec(LocaleCodec); @@ -1037,7 +1037,7 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent* event) } // look up key binding - if (_keyTranslator) { + if (_keyTranslator != nullptr) { KeyboardTranslator::Entry entry = _keyTranslator->findEntry( event->key() , modifiers, diff --git a/src/autotests/DBusTest.cpp b/src/autotests/DBusTest.cpp index 2ad234169..e3d534a47 100644 --- a/src/autotests/DBusTest.cpp +++ b/src/autotests/DBusTest.cpp @@ -32,7 +32,7 @@ void DBusTest::initTestCase() QStringList konsoleServices; if (!QDBusConnection::sessionBus().isConnected() || - !(bus = QDBusConnection::sessionBus().interface())) + ((bus = QDBusConnection::sessionBus().interface()) == nullptr)) QFAIL("Session bus not found"); QDBusReply serviceReply = bus->registeredServiceNames(); diff --git a/src/autotests/PartTest.cpp b/src/autotests/PartTest.cpp index 75403d6e3..bde86eae7 100644 --- a/src/autotests/PartTest.cpp +++ b/src/autotests/PartTest.cpp @@ -60,7 +60,7 @@ void PartTest::testFd() // create a Konsole part and attempt to connect to it KParts::Part* terminalPart = createPart(); - if (!terminalPart) { // not found + if (terminalPart == nullptr) { // not found QSKIP("konsolepart not found."); return; } @@ -102,7 +102,7 @@ KParts::Part* PartTest::createPart() if (!service) // not found return 0; KPluginFactory* factory = KPluginLoader(service->library()).factory(); - if (!factory) // not found + if (factory == nullptr) // not found return 0; KParts::Part* terminalPart = factory->create(this); diff --git a/src/autotests/TerminalInterfaceTest.cpp b/src/autotests/TerminalInterfaceTest.cpp index 2cce10aaa..7f15d5b9d 100644 --- a/src/autotests/TerminalInterfaceTest.cpp +++ b/src/autotests/TerminalInterfaceTest.cpp @@ -48,7 +48,7 @@ void TerminalInterfaceTest::testTerminalInterfaceNoShell() { // create a Konsole part and attempt to connect to it _terminalPart = createPart(); - if (!_terminalPart) + if (_terminalPart == nullptr) QSKIP("konsolepart not found.", SkipSingle); TerminalInterface* terminal = qobject_cast(_terminalPart); @@ -74,7 +74,7 @@ void TerminalInterfaceTest::testTerminalInterface() // create a Konsole part and attempt to connect to it _terminalPart = createPart(); - if (!_terminalPart) + if (_terminalPart == nullptr) QSKIP("konsolepart not found.", SkipSingle); TerminalInterface* terminal = qobject_cast(_terminalPart); @@ -178,7 +178,7 @@ KParts::Part* TerminalInterfaceTest::createPart() if (!service) // not found return 0; KPluginFactory* factory = KPluginLoader(service->library()).factory(); - if (!factory) // not found + if (factory == nullptr) // not found return 0; KParts::Part* terminalPart = factory->create(this); diff --git a/src/settings/ProfileSettings.cpp b/src/settings/ProfileSettings.cpp index 27cef6a8a..8469a2e0e 100644 --- a/src/settings/ProfileSettings.cpp +++ b/src/settings/ProfileSettings.cpp @@ -372,7 +372,7 @@ QList ProfileSettings::selectedProfiles() const { QList list; QItemSelectionModel* selection = sessionTable->selectionModel(); - if (!selection) + if (selection == nullptr) return list; foreach(const QModelIndex & index, selection->selectedIndexes()) { @@ -386,7 +386,7 @@ Profile::Ptr ProfileSettings::currentProfile() const { QItemSelectionModel* selection = sessionTable->selectionModel(); - if (!selection || selection->selectedRows().count() != 1) + if ((selection == nullptr) || selection->selectedRows().count() != 1) return Profile::Ptr(); return selection-> @@ -429,9 +429,9 @@ void StyledBackgroundPainter::drawBackground(QPainter* painter, const QStyleOpti const QModelIndex&) { const QStyleOptionViewItemV3* v3option = qstyleoption_cast(&option); - const QWidget* widget = v3option ? v3option->widget : 0; + const QWidget* widget = v3option != nullptr ? v3option->widget : 0; - QStyle* style = widget ? widget->style() : QApplication::style(); + QStyle* style = widget != nullptr ? widget->style() : QApplication::style(); style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, widget); }