From bb2b49fb1fd9f545a20a0220fc5156f809f7d638 Mon Sep 17 00:00:00 2001 From: Uwe Date: Mon, 18 Jul 2022 03:17:42 +0200 Subject: [PATCH] [Gui] remove superfluous nullptr checks --- src/Gui/Application.cpp | 6 +++--- src/Gui/BitmapFactory.cpp | 2 +- src/Gui/CommandWindow.cpp | 2 +- src/Gui/Control.cpp | 2 +- src/Gui/DlgPreferencesImp.cpp | 2 +- src/Gui/DlgToolbarsImp.cpp | 2 +- src/Gui/ExpressionCompleter.cpp | 4 ++-- src/Gui/FileDialog.cpp | 2 +- src/Gui/MainWindow.cpp | 2 +- src/Gui/ProgressBar.cpp | 2 +- src/Gui/QListWidgetCustom.cpp | 2 +- src/Gui/Quarter/QuarterP.cpp | 2 +- src/Gui/Quarter/QuarterWidget.cpp | 4 ++-- src/Gui/Quarter/SoQTQuarterAdaptor.cpp | 4 ++-- src/Gui/Selection.cpp | 2 +- src/Gui/SoFCCSysDragger.cpp | 8 ++++---- src/Gui/SoFCSelection.cpp | 2 +- src/Gui/SoFCUnifiedSelection.cpp | 2 +- src/Gui/SoNavigationDragger.cpp | 2 +- src/Gui/SpinBox.cpp | 2 +- src/Gui/WidgetFactory.cpp | 4 ++-- src/Gui/WorkbenchFactory.cpp | 4 ++-- 22 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index b26f7719fd..086d60b08e 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -530,7 +530,7 @@ void Application::open(const char* FileName, const char* Module) qApp->processEvents(); // an update is needed otherwise the new view isn't shown } - if (Module != nullptr) { + if (Module) { try { if (File.hasExtension("FCStd")) { bool handled = false; @@ -592,7 +592,7 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch string unicodepath = Base::Tools::escapedUnicodeFromUtf8(File.filePath().c_str()); unicodepath = Base::Tools::escapeEncodeFilename(unicodepath); - if (Module != nullptr) { + if (Module) { try { // issue module loading Command::doCommand(Command::App, "import %s", Module); @@ -683,7 +683,7 @@ void Application::exportTo(const char* FileName, const char* DocName, const char string unicodepath = Base::Tools::escapedUnicodeFromUtf8(File.filePath().c_str()); unicodepath = Base::Tools::escapeEncodeFilename(unicodepath); - if (Module != nullptr) { + if (Module) { try { std::vector sel = Gui::Selection().getObjectsOfType (App::DocumentObject::getClassTypeId(),DocName); diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index 7e6d1fd9bb..1f9537e698 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -115,7 +115,7 @@ BitmapFactoryInst& BitmapFactoryInst::instance(void) void BitmapFactoryInst::destruct (void) { - if (_pcSingleton != nullptr) + if (_pcSingleton) delete _pcSingleton; _pcSingleton = nullptr; } diff --git a/src/Gui/CommandWindow.cpp b/src/Gui/CommandWindow.cpp index 196ce99130..adbe4906f3 100644 --- a/src/Gui/CommandWindow.cpp +++ b/src/Gui/CommandWindow.cpp @@ -376,7 +376,7 @@ protected: Action * action; bool eventFilter(QObject *obj, QEvent *event) { - if (getMainWindow()->findChild() != nullptr && obj == getMainWindow()->statusBar() && ((event->type() == QEvent::Hide) || (event->type() == QEvent::Show))) { + if (getMainWindow()->findChild() && obj == getMainWindow()->statusBar() && ((event->type() == QEvent::Hide) || (event->type() == QEvent::Show))) { this->action->setChecked(getMainWindow()->statusBar()->isVisible()); } return false; diff --git a/src/Gui/Control.cpp b/src/Gui/Control.cpp index 38eb27e7ed..00d3e29616 100644 --- a/src/Gui/Control.cpp +++ b/src/Gui/Control.cpp @@ -263,7 +263,7 @@ ControlSingleton& ControlSingleton::instance(void) void ControlSingleton::destruct (void) { - if (_pcSingleton != nullptr) + if (_pcSingleton) delete _pcSingleton; _pcSingleton = nullptr; } diff --git a/src/Gui/DlgPreferencesImp.cpp b/src/Gui/DlgPreferencesImp.cpp index 0b7dbc11d8..3c81528cde 100644 --- a/src/Gui/DlgPreferencesImp.cpp +++ b/src/Gui/DlgPreferencesImp.cpp @@ -208,7 +208,7 @@ void DlgPreferencesImp::addPage(const std::string& className, const std::string& _pages.push_back(std::make_pair(group, pages)); } - if (DlgPreferencesImp::_activeDialog != nullptr) { + if (DlgPreferencesImp::_activeDialog) { // If the dialog is currently showing, tell it to insert the new page _activeDialog->reloadPages(); } diff --git a/src/Gui/DlgToolbarsImp.cpp b/src/Gui/DlgToolbarsImp.cpp index 3a9245a041..b6a862dacc 100644 --- a/src/Gui/DlgToolbarsImp.cpp +++ b/src/Gui/DlgToolbarsImp.cpp @@ -831,7 +831,7 @@ void DlgCustomToolbarsImp::moveUpCustomCommand(const QString& name, const QByteA continue; } } - if (before != nullptr) { + if (before) { QList group = getActionGroup(*it); bars.front()->removeAction(*it); bars.front()->insertAction(before, *it); diff --git a/src/Gui/ExpressionCompleter.cpp b/src/Gui/ExpressionCompleter.cpp index 392f6cf5f9..d09bfb1211 100644 --- a/src/Gui/ExpressionCompleter.cpp +++ b/src/Gui/ExpressionCompleter.cpp @@ -588,7 +588,7 @@ void ExpressionLineEdit::setDocumentObject(const App::DocumentObject * currentDo completer->setDocumentObject(currentDocObj, checkInList); return; } - if (currentDocObj != nullptr) { + if (currentDocObj) { completer = new ExpressionCompleter(currentDocObj, this, noProperty, checkInList); completer->setWidget(this); completer->setCaseSensitivity(Qt::CaseInsensitive); @@ -701,7 +701,7 @@ void ExpressionTextEdit::setDocumentObject(const App::DocumentObject * currentDo return; } - if (currentDocObj != nullptr) { + if (currentDocObj) { completer = new ExpressionCompleter(currentDocObj, this); if (!exactMatch) completer->setFilterMode(Qt::MatchContains); diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp index fb284b956e..20b9be1f1f 100644 --- a/src/Gui/FileDialog.cpp +++ b/src/Gui/FileDialog.cpp @@ -156,7 +156,7 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, // get the suffix for the filter: use the selected filter if there is one, // otherwise find the first valid suffix in the complete list of filters const QString *filterToSearch; - if (selectedFilter != nullptr) { + if (selectedFilter) { filterToSearch = selectedFilter; } else { diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 8fab549ff6..e8d55876e2 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -643,7 +643,7 @@ void MainWindow::activateWorkbench(const QString& name) ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); bool saveWB = hGrp->GetBool("SaveWBbyTab", false); QMdiSubWindow* subWin = d->mdiArea->activeSubWindow(); - if (subWin /*!= nullptr*/ && saveWB) { + if (subWin && saveWB) { QString currWb = subWin->property("ownWB").toString(); if (currWb.isEmpty() || currWb != name) { subWin->setProperty("ownWB", name); diff --git a/src/Gui/ProgressBar.cpp b/src/Gui/ProgressBar.cpp index fa696abb34..685d9cebc9 100644 --- a/src/Gui/ProgressBar.cpp +++ b/src/Gui/ProgressBar.cpp @@ -553,7 +553,7 @@ void ProgressBar::setupTaskBarProgress() bool ProgressBar::eventFilter(QObject* o, QEvent* e) { - if (sequencer->isRunning() && e != nullptr) { + if (sequencer->isRunning() && e) { QThread* currentThread = QThread::currentThread(); QThread* thr = this->thread(); // this is the main thread if (thr != currentThread) { diff --git a/src/Gui/QListWidgetCustom.cpp b/src/Gui/QListWidgetCustom.cpp index 9c221387f1..75eb889414 100644 --- a/src/Gui/QListWidgetCustom.cpp +++ b/src/Gui/QListWidgetCustom.cpp @@ -46,7 +46,7 @@ QListWidgetCustom::~QListWidgetCustom() */ void QListWidgetCustom::dragMoveEvent(QDragMoveEvent *e) { - if (e->source() != nullptr) { + if (e->source()) { QVariant prop = this->property("OnlyAcceptFrom"); if (prop.isValid()) { QStringList filter = prop.toStringList(); diff --git a/src/Gui/Quarter/QuarterP.cpp b/src/Gui/Quarter/QuarterP.cpp index 2cd533006b..f540a85ac8 100644 --- a/src/Gui/Quarter/QuarterP.cpp +++ b/src/Gui/Quarter/QuarterP.cpp @@ -57,7 +57,7 @@ QuarterP::~QuarterP() delete QuarterP::statecursormap; // FIXME: Why not use an atexit mechanism for this? - if (KeyboardP::keyboardmap != nullptr) { + if (KeyboardP::keyboardmap) { KeyboardP::keyboardmap->clear(); KeyboardP::keypadmap->clear(); delete KeyboardP::keyboardmap; diff --git a/src/Gui/Quarter/QuarterWidget.cpp b/src/Gui/Quarter/QuarterWidget.cpp index daf65aa0b4..1f2f08fd6a 100644 --- a/src/Gui/Quarter/QuarterWidget.cpp +++ b/src/Gui/Quarter/QuarterWidget.cpp @@ -681,7 +681,7 @@ QuarterWidget::setSoRenderManager(SoRenderManager * manager) SoNode * scene = nullptr; SoCamera * camera = nullptr; SbViewportRegion vp; - if (PRIVATE(this)->sorendermanager && (manager != nullptr)) { + if (PRIVATE(this)->sorendermanager && manager) { scene = PRIVATE(this)->sorendermanager->getSceneGraph(); camera = PRIVATE(this)->sorendermanager->getCamera(); vp = PRIVATE(this)->sorendermanager->getViewportRegion(); @@ -726,7 +726,7 @@ QuarterWidget::setSoEventManager(SoEventManager * manager) SoNode * scene = nullptr; SoCamera * camera = nullptr; SbViewportRegion vp; - if (PRIVATE(this)->soeventmanager && (manager != nullptr)) { + if (PRIVATE(this)->soeventmanager && manager) { scene = PRIVATE(this)->soeventmanager->getSceneGraph(); camera = PRIVATE(this)->soeventmanager->getCamera(); vp = PRIVATE(this)->soeventmanager->getViewportRegion(); diff --git a/src/Gui/Quarter/SoQTQuarterAdaptor.cpp b/src/Gui/Quarter/SoQTQuarterAdaptor.cpp index c86ae53314..4e5668ded2 100644 --- a/src/Gui/Quarter/SoQTQuarterAdaptor.cpp +++ b/src/Gui/Quarter/SoQTQuarterAdaptor.cpp @@ -318,10 +318,10 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setViewing(SbBool enable) // Turn off the selection indicators when we go back from picking // mode into viewing mode. - if(m_viewingflag) { + if (m_viewingflag) { SoGLRenderAction* action = getSoRenderManager()->getGLRenderAction(); - if(action != nullptr) + if (action) SoLocateHighlight::turnOffCurrentHighlight(action); } } diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index 01f96d5851..fb1b5e7f52 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -1825,7 +1825,7 @@ SelectionSingleton& SelectionSingleton::instance(void) void SelectionSingleton::destruct (void) { - if (_pcSingleton != nullptr) + if (_pcSingleton) delete _pcSingleton; _pcSingleton = nullptr; } diff --git a/src/Gui/SoFCCSysDragger.cpp b/src/Gui/SoFCCSysDragger.cpp index 1e89a52a5f..683026083c 100644 --- a/src/Gui/SoFCCSysDragger.cpp +++ b/src/Gui/SoFCCSysDragger.cpp @@ -318,7 +318,7 @@ SbBool TDragger::setUpConnections(SbBool onoff, SbBool doitalways) } else { - if (this->fieldSensor.getAttachedField() != nullptr) + if (this->fieldSensor.getAttachedField()) this->fieldSensor.detach(); inherited::setUpConnections(onoff, doitalways); } @@ -603,7 +603,7 @@ SbBool RDragger::setUpConnections(SbBool onoff, SbBool doitalways) } else { - if (this->fieldSensor.getAttachedField() != nullptr) + if (this->fieldSensor.getAttachedField()) this->fieldSensor.detach(); inherited::setUpConnections(onoff, doitalways); } @@ -857,10 +857,10 @@ SbBool SoFCCSysDragger::setUpConnections(SbBool onoff, SbBool doitalways) inherited::setUpConnections(onoff, doitalways); - if (this->translationSensor.getAttachedField() != nullptr) + if (this->translationSensor.getAttachedField()) this->translationSensor.detach(); - if (this->rotationSensor.getAttachedField() != nullptr) + if (this->rotationSensor.getAttachedField()) this->rotationSensor.detach(); } return !(this->connectionsSetUp = onoff); diff --git a/src/Gui/SoFCSelection.cpp b/src/Gui/SoFCSelection.cpp index 7017ac4920..6c1e88076d 100644 --- a/src/Gui/SoFCSelection.cpp +++ b/src/Gui/SoFCSelection.cpp @@ -117,7 +117,7 @@ SoFCSelection::~SoFCSelection() { // If we're being deleted and we're the current highlight, // NULL out that variable - if (currenthighlight != nullptr && + if (currenthighlight && (!currenthighlight->getTail()->isOfType(SoFCSelection::getClassTypeId()))) { currenthighlight->unref(); currenthighlight = nullptr; diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index 384fce8c91..83af95d097 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -137,7 +137,7 @@ SoFCUnifiedSelection::~SoFCUnifiedSelection() { // If we're being deleted and we're the current highlight, // NULL out that variable - if (currenthighlight != nullptr) { + if (currenthighlight) { currenthighlight->unref(); currenthighlight = nullptr; } diff --git a/src/Gui/SoNavigationDragger.cpp b/src/Gui/SoNavigationDragger.cpp index 75ac8715cc..5a9cc40a7e 100644 --- a/src/Gui/SoNavigationDragger.cpp +++ b/src/Gui/SoNavigationDragger.cpp @@ -374,7 +374,7 @@ RotTransDragger::invalidateSurroundScaleCB(void *parent, SoDragger *) // Invalidate the surroundScale, if it exists. SoSurroundScale *mySS = SO_CHECK_PART( myParentDragger, "surroundScale", SoSurroundScale); - if (mySS != nullptr) + if (mySS) mySS->invalidate(); } diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index 39fdf910b2..b958e0fb07 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -171,7 +171,7 @@ void ExpressionSpinBox::openFormulaDialog() PropertyQuantity * qprop = freecad_dynamic_cast(getPath().getProperty()); Unit unit; - if (qprop != nullptr) + if (qprop) unit = qprop->getUnit(); Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), unit, spinbox); diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index 860bf22c60..83d76281f8 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -53,14 +53,14 @@ Gui::WidgetFactoryInst* Gui::WidgetFactoryInst::_pcSingleton = nullptr; WidgetFactoryInst& WidgetFactoryInst::instance() { - if (_pcSingleton == nullptr) + if (!_pcSingleton) _pcSingleton = new WidgetFactoryInst; return *_pcSingleton; } void WidgetFactoryInst::destruct () { - if (_pcSingleton != nullptr) + if (_pcSingleton) delete _pcSingleton; _pcSingleton = nullptr; } diff --git a/src/Gui/WorkbenchFactory.cpp b/src/Gui/WorkbenchFactory.cpp index 3a1b9e8270..f8a364c2fa 100644 --- a/src/Gui/WorkbenchFactory.cpp +++ b/src/Gui/WorkbenchFactory.cpp @@ -32,14 +32,14 @@ Gui::WorkbenchFactoryInst* Gui::WorkbenchFactoryInst::_pcSingleton = nullptr; WorkbenchFactoryInst& WorkbenchFactoryInst::instance() { - if (_pcSingleton == nullptr) + if (!_pcSingleton) _pcSingleton = new WorkbenchFactoryInst; return *_pcSingleton; } void WorkbenchFactoryInst::destruct () { - if ( _pcSingleton != nullptr ) + if (_pcSingleton) delete _pcSingleton; _pcSingleton = nullptr; }