mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Simplify code
This commit is contained in:
parent
79e85d01fa
commit
9a00839a75
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
BitTorrent::TorrentID BitTorrent::TorrentID::fromSHA1Hash(const SHA1Hash &hash)
|
||||
{
|
||||
return TorrentID(hash);
|
||||
return {hash};
|
||||
}
|
||||
|
||||
BitTorrent::TorrentID BitTorrent::TorrentID::fromSHA256Hash(const SHA256Hash &hash)
|
||||
|
@ -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;
|
||||
|
@ -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})
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,7 @@ DesktopIntegration::DesktopIntegration(QObject *parent)
|
||||
|
||||
DesktopIntegration::~DesktopIntegration()
|
||||
{
|
||||
if (m_menu)
|
||||
delete m_menu;
|
||||
delete m_menu;
|
||||
}
|
||||
|
||||
bool DesktopIntegration::isActive() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user