diff --git a/app/backend/autoupdatechecker.cpp b/app/backend/autoupdatechecker.cpp index 8c1e14d4..989a62fb 100644 --- a/app/backend/autoupdatechecker.cpp +++ b/app/backend/autoupdatechecker.cpp @@ -15,8 +15,8 @@ AutoUpdateChecker::AutoUpdateChecker(QObject *parent) : // Allow HTTP redirects m_Nam.setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy); - connect(&m_Nam, SIGNAL(finished(QNetworkReply*)), - this, SLOT(handleUpdateCheckRequestFinished(QNetworkReply*))); + connect(&m_Nam, &QNetworkAccessManager::finished, + this, &AutoUpdateChecker::handleUpdateCheckRequestFinished); QString currentVersion(VERSION_STR); qDebug() << "Current Moonlight version:" << currentVersion; diff --git a/app/backend/boxartmanager.cpp b/app/backend/boxartmanager.cpp index bb474d53..62e3158b 100644 --- a/app/backend/boxartmanager.cpp +++ b/app/backend/boxartmanager.cpp @@ -46,8 +46,8 @@ public: m_Computer(computer), m_App(app) { - connect(this, SIGNAL(boxArtFetchCompleted(NvComputer*,NvApp,QUrl)), - boxArtManager, SLOT(handleBoxArtLoadComplete(NvComputer*,NvApp,QUrl))); + connect(this, &NetworkBoxArtLoadTask::boxArtFetchCompleted, + boxArtManager, &BoxArtManager::handleBoxArtLoadComplete); } signals: diff --git a/app/backend/computermanager.cpp b/app/backend/computermanager.cpp index d54c624b..77d95302 100644 --- a/app/backend/computermanager.cpp +++ b/app/backend/computermanager.cpp @@ -164,7 +164,7 @@ ComputerManager::ComputerManager(QObject *parent) // because NvHTTP uses aboutToQuit() to abort requests in progres // while quitting, however this is a one time signal - additional // requests would not be aborted and block termination. - connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(handleAboutToQuit())); + connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &ComputerManager::handleAboutToQuit); } ComputerManager::~ComputerManager() @@ -302,8 +302,8 @@ void ComputerManager::startPollingComputer(NvComputer* computer) if (!pollingEntry->isActive()) { PcMonitorThread* thread = new PcMonitorThread(computer); - connect(thread, SIGNAL(computerStateChanged(NvComputer*)), - this, SLOT(handleComputerStateChanged(NvComputer*))); + connect(thread, &PcMonitorThread::computerStateChanged, + this, &ComputerManager::handleComputerStateChanged); pollingEntry->setActiveThread(thread); thread->start(); } @@ -337,7 +337,6 @@ void ComputerManager::handleMdnsServiceResolved(MdnsPendingComputer* computer, address.isInSubnet(QHostAddress("fec0::"), 10) || address.isInSubnet(QHostAddress("fc00::"), 7)) { addNewHost(address.toString(), true, v6Global); - added = true; break; } } @@ -418,7 +417,7 @@ void ComputerManager::deleteHost(NvComputer* computer) void ComputerManager::renameHost(NvComputer* computer, QString name) { { - QWriteLocker(&computer->lock); + QWriteLocker lock(&computer->lock); computer->name = name; computer->hasCustomName = true; diff --git a/app/backend/computermanager.h b/app/backend/computermanager.h index 57593632..9882d299 100644 --- a/app/backend/computermanager.h +++ b/app/backend/computermanager.h @@ -70,7 +70,7 @@ private: m_Resolver = new QMdnsEngine::Resolver(m_Server, m_Hostname); connect(m_Resolver, &QMdnsEngine::Resolver::resolved, this, &MdnsPendingComputer::handleResolvedAddress); - QTimer::singleShot(2000, this, SLOT(handleResolvedTimeout())); + QTimer::singleShot(2000, this, &MdnsPendingComputer::handleResolvedTimeout); } QByteArray m_Hostname; diff --git a/app/backend/identitymanager.cpp b/app/backend/identitymanager.cpp index 95bb9768..51ea5d90 100644 --- a/app/backend/identitymanager.cpp +++ b/app/backend/identitymanager.cpp @@ -143,7 +143,7 @@ QSslKey IdentityManager::getSslKey() { if (m_CachedSslKey.isNull()) { - BIO* bio = BIO_new_mem_buf(m_CachedPrivateKey.data(), -1); + BIO* bio = BIO_new_mem_buf(m_CachedPrivateKey.constData(), -1); THROW_BAD_ALLOC_IF_NULL(bio); EVP_PKEY* pk = PEM_read_bio_PrivateKey(bio, nullptr, nullptr, nullptr); diff --git a/app/backend/nvcomputer.cpp b/app/backend/nvcomputer.cpp index 9bd37bbe..f3180912 100644 --- a/app/backend/nvcomputer.cpp +++ b/app/backend/nvcomputer.cpp @@ -30,6 +30,7 @@ NvComputer::NvComputer(QSettings& settings) this->serverCert = QSslCertificate(settings.value(SER_SRVCERT).toByteArray()); int appCount = settings.beginReadArray(SER_APPLIST); + this->appList.reserve(appCount); for (int i = 0; i < appCount; i++) { settings.setArrayIndex(i); @@ -98,7 +99,7 @@ NvComputer::NvComputer(QString address, QString serverInfo, QSslCertificate serv QString newMacString = NvHTTP::getXmlString(serverInfo, "mac"); if (newMacString != "00:00:00:00:00:00") { QStringList macOctets = newMacString.split(':'); - for (QString macOctet : macOctets) { + for (const QString& macOctet : macOctets) { this->macAddress.append((char) macOctet.toInt(nullptr, 16)); } } diff --git a/app/backend/nvhttp.cpp b/app/backend/nvhttp.cpp index 3826a298..8be5b88e 100644 --- a/app/backend/nvhttp.cpp +++ b/app/backend/nvhttp.cpp @@ -67,7 +67,8 @@ NvHTTP::parseQuad(QString quad) } QStringList parts = quad.split("."); - for (int i = 0; i < 4; i++) + ret.reserve(parts.length()); + for (int i = 0; i < parts.length(); i++) { ret.append(parts.at(i).toInt()); } @@ -391,7 +392,7 @@ void NvHTTP::handleSslErrors(QNetworkReply* reply, const QList& error return; } - for (auto error : errors) { + for (const QSslError& error : errors) { if (m_ServerCert != error.certificate()) { ignoreErrors = false; break; @@ -462,10 +463,10 @@ NvHTTP::openConnection(QUrl baseUrl, // Run the request with a timeout if requested QEventLoop loop; - connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); - connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), &loop, SLOT(quit())); + connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit); + connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, &loop, &QEventLoop::quit); if (timeoutMs) { - QTimer::singleShot(timeoutMs, &loop, SLOT(quit())); + QTimer::singleShot(timeoutMs, &loop, &QEventLoop::quit); } if (logLevel >= NvLogLevel::NVLL_VERBOSE) { qInfo() << "Executing request:" << url.toString(); diff --git a/app/backend/nvhttp.h b/app/backend/nvhttp.h index 69041497..26c49b7c 100644 --- a/app/backend/nvhttp.h +++ b/app/backend/nvhttp.h @@ -23,6 +23,7 @@ public: int height; int refreshRate; }; +Q_DECLARE_TYPEINFO(NvDisplayMode, Q_PRIMITIVE_TYPE); class GfeHttpResponseException : public std::exception { diff --git a/app/backend/nvpairingmanager.cpp b/app/backend/nvpairingmanager.cpp index eba7e1f0..6053e8be 100644 --- a/app/backend/nvpairingmanager.cpp +++ b/app/backend/nvpairingmanager.cpp @@ -215,7 +215,7 @@ NvPairingManager::pair(QString appVersion, QString pin, QSslCertificate& serverC QByteArray salt = generateRandomBytes(16); QByteArray saltedPin = saltPin(salt, pin); - QByteArray aesKey = QCryptographicHash::hash(saltedPin, hashAlgo).data(); + QByteArray aesKey = QCryptographicHash::hash(saltedPin, hashAlgo).constData(); aesKey.truncate(16); QString getCert = m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, diff --git a/app/cli/commandlineparser.cpp b/app/cli/commandlineparser.cpp index 220858c0..aa7af24c 100644 --- a/app/cli/commandlineparser.cpp +++ b/app/cli/commandlineparser.cpp @@ -52,7 +52,7 @@ public: void handleUnknownOptions() { - if (unknownOptionNames().length()) { + if (!unknownOptionNames().isEmpty()) { showError(QString("Unknown options: %1").arg(unknownOptionNames().join(", "))); } } @@ -325,25 +325,21 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference // Resolve display's width and height QRegularExpression resolutionRexExp("^(720|1080|1440|4K|resolution)$"); QStringList resoOptions = parser.optionNames().filter(resolutionRexExp); - bool displaySet = resoOptions.length(); + bool displaySet = !resoOptions.isEmpty(); if (displaySet) { QString name = resoOptions.last(); if (name == "720") { preferences->width = 1280; preferences->height = 720; - displaySet = true; } else if (name == "1080") { preferences->width = 1920; preferences->height = 1080; - displaySet = true; } else if (name == "1440") { preferences->width = 2560; preferences->height = 1440; - displaySet = true; } else if (name == "4K") { preferences->width = 3840; preferences->height = 2160; - displaySet = true; } else if (name == "resolution") { auto resolution = parser.getResolutionOptionValue(name); preferences->width = resolution.first; diff --git a/app/gui/sdlgamepadkeynavigation.cpp b/app/gui/sdlgamepadkeynavigation.cpp index 006032b7..4e9f1952 100644 --- a/app/gui/sdlgamepadkeynavigation.cpp +++ b/app/gui/sdlgamepadkeynavigation.cpp @@ -15,7 +15,7 @@ SdlGamepadKeyNavigation::SdlGamepadKeyNavigation() m_LastAxisNavigationEventTime(0) { m_PollingTimer = new QTimer(this); - connect(m_PollingTimer, SIGNAL(timeout()), this, SLOT(onPollingTimerFired())); + connect(m_PollingTimer, &QTimer::timeout, this, &SdlGamepadKeyNavigation::onPollingTimerFired); } SdlGamepadKeyNavigation::~SdlGamepadKeyNavigation() diff --git a/app/settings/mappingfetcher.cpp b/app/settings/mappingfetcher.cpp index f70a7981..8e59fcae 100644 --- a/app/settings/mappingfetcher.cpp +++ b/app/settings/mappingfetcher.cpp @@ -13,8 +13,8 @@ MappingFetcher::MappingFetcher(QObject *parent) : // Allow HTTP redirects m_Nam.setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy); - connect(&m_Nam, SIGNAL(finished(QNetworkReply*)), - this, SLOT(handleMappingListFetched(QNetworkReply*))); + connect(&m_Nam, &QNetworkAccessManager::finished, + this, &MappingFetcher::handleMappingListFetched); } void MappingFetcher::start() diff --git a/app/settings/mappingmanager.cpp b/app/settings/mappingmanager.cpp index e9a4bf6e..be9a1a8d 100644 --- a/app/settings/mappingmanager.cpp +++ b/app/settings/mappingmanager.cpp @@ -41,7 +41,7 @@ MappingManager::MappingManager() #else .split('\n', QString::SkipEmptyParts); #endif - for (QString sdlMapping : sdlMappings) { + for (const QString& sdlMapping : sdlMappings) { SdlGamepadMapping mapping(sdlMapping); addMapping(mapping); } diff --git a/app/streaming/video/ffmpeg-renderers/vt.mm b/app/streaming/video/ffmpeg-renderers/vt.mm index 140e7a9b..39b54dc0 100644 --- a/app/streaming/video/ffmpeg-renderers/vt.mm +++ b/app/streaming/video/ffmpeg-renderers/vt.mm @@ -281,8 +281,8 @@ public: // Queue this sample for the next v-sync CMSampleTimingInfo timingInfo = { .duration = kCMTimeInvalid, + .presentationTimeStamp = CMClockMakeHostTimeFromSystemUnits(mach_absolute_time()), .decodeTimeStamp = kCMTimeInvalid, - .presentationTimeStamp = CMClockMakeHostTimeFromSystemUnits(mach_absolute_time()) }; CMSampleBufferRef sampleBuffer; @@ -365,6 +365,7 @@ public: if ([device.name containsString:@" 5"]) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "No HEVC Main10 support on Skylake iGPU"); + [device release]; return false; } } @@ -375,10 +376,13 @@ public: [device.name containsString:@" M3"]) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "No HEVC Main10 support on AMD GPUs until Polaris"); + [device release]; return false; } } } + + [device release]; } else #endif