Browse Source

Merge pull request #11961 from NotTsunami/master

Remove redundant null checks
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
fa43dab3a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/base/bittorrent/session.cpp
  2. 2
      src/base/iconprovider.cpp
  3. 2
      src/base/logger.cpp
  4. 2
      src/base/net/downloadmanager.cpp
  5. 8
      src/base/net/geoipmanager.cpp
  6. 1
      src/base/net/private/downloadhandlerimpl.cpp
  7. 2
      src/base/net/proxyconfigurationmanager.cpp
  8. 2
      src/base/preferences.cpp
  9. 2
      src/base/scanfoldersmodel.cpp
  10. 1
      src/base/search/searchpluginmanager.cpp
  11. 7
      src/gui/mainwindow.cpp
  12. 2
      src/gui/private/fspathedit_p.cpp
  13. 2
      src/gui/uithememanager.cpp
  14. 6
      src/webui/webui.cpp

4
src/base/bittorrent/session.cpp

@ -977,7 +977,6 @@ Session::~Session()
// We must delete FilterParserThread // We must delete FilterParserThread
// before we delete lt::session // before we delete lt::session
if (m_filterParser)
delete m_filterParser; delete m_filterParser;
// We must delete PortForwarderImpl before // We must delete PortForwarderImpl before
@ -1002,10 +1001,8 @@ void Session::initInstance()
void Session::freeInstance() void Session::freeInstance()
{ {
if (m_instance) {
delete m_instance; delete m_instance;
m_instance = nullptr; m_instance = nullptr;
}
} }
Session *Session::instance() Session *Session::instance()
@ -1605,7 +1602,6 @@ void Session::enableTracker(const bool enable)
m_tracker->start(); m_tracker->start();
} }
else { else {
if (m_tracker)
delete m_tracker; delete m_tracker;
} }
} }

2
src/base/iconprovider.cpp

@ -46,10 +46,8 @@ void IconProvider::initInstance()
void IconProvider::freeInstance() void IconProvider::freeInstance()
{ {
if (m_instance) {
delete m_instance; delete m_instance;
m_instance = nullptr; m_instance = nullptr;
}
} }
IconProvider *IconProvider::instance() IconProvider *IconProvider::instance()

2
src/base/logger.cpp

@ -65,10 +65,8 @@ void Logger::initInstance()
void Logger::freeInstance() void Logger::freeInstance()
{ {
if (m_instance) {
delete m_instance; delete m_instance;
m_instance = nullptr; m_instance = nullptr;
}
} }
void Logger::addMessage(const QString &message, const Log::MsgType &type) void Logger::addMessage(const QString &message, const Log::MsgType &type)

2
src/base/net/downloadmanager.cpp

@ -152,10 +152,8 @@ void Net::DownloadManager::initInstance()
void Net::DownloadManager::freeInstance() void Net::DownloadManager::freeInstance()
{ {
if (m_instance) {
delete m_instance; delete m_instance;
m_instance = nullptr; m_instance = nullptr;
}
} }
Net::DownloadManager *Net::DownloadManager::instance() Net::DownloadManager *Net::DownloadManager::instance()

8
src/base/net/geoipmanager.cpp

@ -63,7 +63,6 @@ GeoIPManager::GeoIPManager()
GeoIPManager::~GeoIPManager() GeoIPManager::~GeoIPManager()
{ {
if (m_geoIPDatabase)
delete m_geoIPDatabase; delete m_geoIPDatabase;
} }
@ -75,10 +74,8 @@ void GeoIPManager::initInstance()
void GeoIPManager::freeInstance() void GeoIPManager::freeInstance()
{ {
if (m_instance) {
delete m_instance; delete m_instance;
m_instance = nullptr; m_instance = nullptr;
}
} }
GeoIPManager *GeoIPManager::instance() GeoIPManager *GeoIPManager::instance()
@ -88,10 +85,8 @@ GeoIPManager *GeoIPManager::instance()
void GeoIPManager::loadDatabase() void GeoIPManager::loadDatabase()
{ {
if (m_geoIPDatabase) {
delete m_geoIPDatabase; delete m_geoIPDatabase;
m_geoIPDatabase = nullptr; m_geoIPDatabase = nullptr;
}
const QString filepath = Utils::Fs::expandPathAbs( const QString filepath = Utils::Fs::expandPathAbs(
QString("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEOIP_FOLDER, GEOIP_FILENAME)); QString("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEOIP_FOLDER, GEOIP_FILENAME));
@ -398,7 +393,7 @@ void GeoIPManager::configure()
if (m_enabled && !m_geoIPDatabase) { if (m_enabled && !m_geoIPDatabase) {
loadDatabase(); loadDatabase();
} }
else if (!m_enabled && m_geoIPDatabase) { else if (!m_enabled) {
delete m_geoIPDatabase; delete m_geoIPDatabase;
m_geoIPDatabase = nullptr; m_geoIPDatabase = nullptr;
} }
@ -423,7 +418,6 @@ void GeoIPManager::downloadFinished(const DownloadResult &result)
GeoIPDatabase *geoIPDatabase = GeoIPDatabase::load(data, error); GeoIPDatabase *geoIPDatabase = GeoIPDatabase::load(data, error);
if (geoIPDatabase) { if (geoIPDatabase) {
if (!m_geoIPDatabase || (geoIPDatabase->buildEpoch() > m_geoIPDatabase->buildEpoch())) { if (!m_geoIPDatabase || (geoIPDatabase->buildEpoch() > m_geoIPDatabase->buildEpoch())) {
if (m_geoIPDatabase)
delete m_geoIPDatabase; delete m_geoIPDatabase;
m_geoIPDatabase = geoIPDatabase; m_geoIPDatabase = geoIPDatabase;
LogMsg(tr("GeoIP database loaded. Type: %1. Build time: %2.") LogMsg(tr("GeoIP database loaded. Type: %1. Build time: %2.")

1
src/base/net/private/downloadhandlerimpl.cpp

@ -63,7 +63,6 @@ DownloadHandlerImpl::DownloadHandlerImpl(const Net::DownloadRequest &downloadReq
DownloadHandlerImpl::~DownloadHandlerImpl() DownloadHandlerImpl::~DownloadHandlerImpl()
{ {
if (m_reply)
delete m_reply; delete m_reply;
} }

2
src/base/net/proxyconfigurationmanager.cpp

@ -84,10 +84,8 @@ void ProxyConfigurationManager::initInstance()
void ProxyConfigurationManager::freeInstance() void ProxyConfigurationManager::freeInstance()
{ {
if (m_instance) {
delete m_instance; delete m_instance;
m_instance = nullptr; m_instance = nullptr;
}
} }
ProxyConfigurationManager *ProxyConfigurationManager::instance() ProxyConfigurationManager *ProxyConfigurationManager::instance()

2
src/base/preferences.cpp

@ -77,10 +77,8 @@ void Preferences::initInstance()
void Preferences::freeInstance() void Preferences::freeInstance()
{ {
if (m_instance) {
delete m_instance; delete m_instance;
m_instance = nullptr; m_instance = nullptr;
}
} }
const QVariant Preferences::value(const QString &key, const QVariant &defaultValue) const const QVariant Preferences::value(const QString &key, const QVariant &defaultValue) const

2
src/base/scanfoldersmodel.cpp

@ -69,10 +69,8 @@ bool ScanFoldersModel::initInstance(QObject *parent)
void ScanFoldersModel::freeInstance() void ScanFoldersModel::freeInstance()
{ {
if (m_instance) {
delete m_instance; delete m_instance;
m_instance = nullptr; m_instance = nullptr;
}
} }
ScanFoldersModel *ScanFoldersModel::instance() ScanFoldersModel *ScanFoldersModel::instance()

1
src/base/search/searchpluginmanager.cpp

@ -104,7 +104,6 @@ SearchPluginManager *SearchPluginManager::instance()
void SearchPluginManager::freeInstance() void SearchPluginManager::freeInstance()
{ {
if (m_instance)
delete m_instance; delete m_instance;
} }

7
src/gui/mainwindow.cpp

@ -678,7 +678,7 @@ void MainWindow::displayRSSTab(bool enable)
#endif #endif
} }
} }
else if (m_rssWidget) { else {
delete m_rssWidget; delete m_rssWidget;
} }
} }
@ -714,7 +714,7 @@ void MainWindow::displaySearchTab(bool enable)
tr("Search")); tr("Search"));
} }
} }
else if (m_searchWidget) { else {
delete m_searchWidget; delete m_searchWidget;
} }
} }
@ -1170,7 +1170,6 @@ void MainWindow::closeEvent(QCloseEvent *e)
} }
// abort search if any // abort search if any
if (m_searchWidget)
delete m_searchWidget; delete m_searchWidget;
hide(); hide();
@ -1875,7 +1874,7 @@ void MainWindow::on_actionExecutionLogs_triggered(bool checked)
m_tabs->setTabIcon(indexTab, UIThemeManager::instance()->getIcon("view-calendar-journal")); m_tabs->setTabIcon(indexTab, UIThemeManager::instance()->getIcon("view-calendar-journal"));
#endif #endif
} }
else if (m_executionLog) { else {
delete m_executionLog; delete m_executionLog;
} }

2
src/gui/private/fspathedit_p.cpp

@ -259,11 +259,9 @@ void Private::FileLineEdit::keyPressEvent(QKeyEvent *e)
FileSystemPathValidator::TestResult lastTestResult = validator->lastTestResult(); FileSystemPathValidator::TestResult lastTestResult = validator->lastTestResult();
QValidator::State lastState = validator->lastValidationState(); QValidator::State lastState = validator->lastValidationState();
if (lastTestResult == FileSystemPathValidator::TestResult::OK) { if (lastTestResult == FileSystemPathValidator::TestResult::OK) {
if (m_warningAction) {
delete m_warningAction; delete m_warningAction;
m_warningAction = nullptr; m_warningAction = nullptr;
} }
}
else { else {
if (!m_warningAction) { if (!m_warningAction) {
m_warningAction = new QAction(this); m_warningAction = new QAction(this);

2
src/gui/uithememanager.cpp

@ -43,10 +43,8 @@ UIThemeManager *UIThemeManager::m_instance = nullptr;
void UIThemeManager::freeInstance() void UIThemeManager::freeInstance()
{ {
if (m_instance) {
delete m_instance; delete m_instance;
m_instance = nullptr; m_instance = nullptr;
}
} }
void UIThemeManager::initInstance() void UIThemeManager::initInstance()

6
src/webui/webui.cpp

@ -127,20 +127,14 @@ void WebUI::configure()
m_dnsUpdater->updateCredentials(); m_dnsUpdater->updateCredentials();
} }
else { else {
if (m_dnsUpdater)
delete m_dnsUpdater; delete m_dnsUpdater;
} }
} }
else { else {
Net::PortForwarder::instance()->deletePort(oldPort); Net::PortForwarder::instance()->deletePort(oldPort);
if (m_httpServer)
delete m_httpServer; delete m_httpServer;
if (m_webapp)
delete m_webapp; delete m_webapp;
if (m_dnsUpdater)
delete m_dnsUpdater; delete m_dnsUpdater;
} }
} }

Loading…
Cancel
Save