Browse Source

Simplify code

adaptive-webui-19844
Chocobo1 1 year ago
parent
commit
9a00839a75
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 4
      src/app/qtlocalpeer/qtlocalpeer.cpp
  2. 4
      src/base/bittorrent/filterparserthread.cpp
  3. 4
      src/base/bittorrent/infohash.cpp
  4. 2
      src/base/bittorrent/sessionimpl.h
  5. 2
      src/base/bittorrent/torrentimpl.cpp
  6. 4
      src/base/profile_p.cpp
  7. 3
      src/gui/desktopintegration.cpp

4
src/app/qtlocalpeer/qtlocalpeer.cpp

@ -152,10 +152,10 @@ bool QtLocalPeer::sendMessage(const QString &message, const int timeout) @@ -152,10 +152,10 @@ bool QtLocalPeer::sendMessage(const QString &message, const int timeout)
break;
int ms = 250;
#if defined(Q_OS_WIN)
Sleep(DWORD(ms));
::Sleep(DWORD(ms));
#else
struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
nanosleep(&ts, NULL);
::nanosleep(&ts, nullptr);
#endif
}
if (!connOk)

4
src/base/bittorrent/filterparserthread.cpp

@ -484,9 +484,9 @@ int FilterParserThread::parseP2BFilterFile() @@ -484,9 +484,9 @@ int FilterParserThread::parseP2BFilterFile()
char buf[7];
unsigned char version;
if (!stream.readRawData(buf, sizeof(buf))
|| memcmp(buf, "\xFF\xFF\xFF\xFFP2B", 7)
|| (memcmp(buf, "\xFF\xFF\xFF\xFFP2B", 7) != 0)
|| !stream.readRawData(reinterpret_cast<char*>(&version), sizeof(version)))
{
{
LogMsg(tr("Parsing Error: The filter file is not a valid PeerGuardian P2B file."), Log::CRITICAL);
return ruleCount;
}

4
src/base/bittorrent/infohash.cpp

@ -93,7 +93,7 @@ BitTorrent::InfoHash::operator WrappedType() const @@ -93,7 +93,7 @@ BitTorrent::InfoHash::operator WrappedType() const
BitTorrent::TorrentID BitTorrent::TorrentID::fromString(const QString &hashString)
{
return TorrentID(BaseType::fromString(hashString));
return {BaseType::fromString(hashString)};
}
BitTorrent::TorrentID BitTorrent::TorrentID::fromInfoHash(const BitTorrent::InfoHash &infoHash)
@ -103,7 +103,7 @@ BitTorrent::TorrentID BitTorrent::TorrentID::fromInfoHash(const BitTorrent::Info @@ -103,7 +103,7 @@ BitTorrent::TorrentID BitTorrent::TorrentID::fromInfoHash(const BitTorrent::Info
BitTorrent::TorrentID BitTorrent::TorrentID::fromSHA1Hash(const SHA1Hash &hash)
{
return TorrentID(hash);
return {hash};
}
BitTorrent::TorrentID BitTorrent::TorrentID::fromSHA256Hash(const SHA256Hash &hash)

2
src/base/bittorrent/sessionimpl.h

@ -380,7 +380,7 @@ namespace BitTorrent @@ -380,7 +380,7 @@ namespace BitTorrent
bool isExcludedFileNamesEnabled() const override;
void setExcludedFileNamesEnabled(bool enabled) override;
QStringList excludedFileNames() const override;
void setExcludedFileNames(const QStringList &newList) override;
void setExcludedFileNames(const QStringList &excludedFileNames) override;
bool isFilenameExcluded(const QString &fileName) const override;
QStringList bannedIPs() const override;
void setBannedIPs(const QStringList &newList) override;

2
src/base/bittorrent/torrentimpl.cpp

@ -98,7 +98,7 @@ namespace @@ -98,7 +98,7 @@ namespace
QString firstTrackerMessage;
QString firstErrorMessage;
#ifdef QBT_USES_LIBTORRENT2
const auto numEndpoints = static_cast<qsizetype>(nativeEntry.endpoints.size() * ((hashes.has_v1() && hashes.has_v2()) ? 2 : 1));
const auto numEndpoints = static_cast<qsizetype>(nativeEntry.endpoints.size()) * ((hashes.has_v1() && hashes.has_v2()) ? 2 : 1);
for (const lt::announce_endpoint &endpoint : nativeEntry.endpoints)
{
for (const auto protocolVersion : {lt::protocol_version::V1, lt::protocol_version::V2})

4
src/base/profile_p.cpp

@ -116,9 +116,9 @@ Path Private::DefaultProfile::downloadLocation() const @@ -116,9 +116,9 @@ Path Private::DefaultProfile::downloadLocation() const
std::unique_ptr<QSettings> Private::DefaultProfile::applicationSettings(const QString &name) const
{
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
return std::unique_ptr<QSettings>(new QSettings(QSettings::IniFormat, QSettings::UserScope, profileName(), name));
return std::make_unique<QSettings>(QSettings::IniFormat, QSettings::UserScope, profileName(), name);
#else
return std::unique_ptr<QSettings>(new QSettings(profileName(), name));
return std::make_unique<QSettings>(profileName(), name);
#endif
}

3
src/gui/desktopintegration.cpp

@ -100,8 +100,7 @@ DesktopIntegration::DesktopIntegration(QObject *parent) @@ -100,8 +100,7 @@ DesktopIntegration::DesktopIntegration(QObject *parent)
DesktopIntegration::~DesktopIntegration()
{
if (m_menu)
delete m_menu;
delete m_menu;
}
bool DesktopIntegration::isActive() const

Loading…
Cancel
Save