From a2f627183243ef2006b0f0f9283e6aa9e6ac7b7e Mon Sep 17 00:00:00 2001 From: Lord-Grey Date: Sat, 9 Sep 2023 22:10:22 +0200 Subject: [PATCH] Correct compile errorswith Qt6.7 --- include/grabber/AudioGrabberWindows.h | 2 +- include/hyperion/ImageToLedsMap.h | 10 ++++++--- libsrc/api/JsonAPI.cpp | 4 ++-- libsrc/api/JsonCB.cpp | 2 +- libsrc/db/DBManager.cpp | 11 +++++----- libsrc/effectengine/EffectFileHandler.cpp | 12 +++++----- libsrc/forwarder/MessageForwarder.cpp | 10 ++++----- libsrc/grabber/audio/AudioGrabberWindows.cpp | 5 ++++- libsrc/grabber/qt/QtGrabber.cpp | 2 +- libsrc/hyperion/ComponentRegister.cpp | 2 +- libsrc/hyperion/SettingsManager.cpp | 22 +++++++++---------- .../leddevice/dev_net/LedDevicePhilipsHue.cpp | 2 +- libsrc/leddevice/dev_net/LedDeviceWled.cpp | 8 +++---- libsrc/utils/Logger.cpp | 2 +- .../utils/jsonschema/QJsonSchemaChecker.cpp | 4 ++-- src/hyperion-remote/hyperion-remote.cpp | 4 ++-- src/hyperiond/main.cpp | 4 ++-- 17 files changed, 57 insertions(+), 49 deletions(-) diff --git a/include/grabber/AudioGrabberWindows.h b/include/grabber/AudioGrabberWindows.h index 747212c2..99056298 100644 --- a/include/grabber/AudioGrabberWindows.h +++ b/include/grabber/AudioGrabberWindows.h @@ -64,7 +64,7 @@ static BOOL CALLBACK DirectSoundEnumProcessor(LPGUID deviceIdGuid, LPCTSTR devic CoTaskMemFree(deviceIdStr); // Process Device Information - QString deviceName = QString::fromLocal8Bit(deviceDescStr); + QString deviceName = QString::fromWCharArray(deviceDescStr); Debug(Logger::getInstance("AUDIOGRABBER"), "Found Audio Device: %s", deviceDescStr); diff --git a/include/hyperion/ImageToLedsMap.h b/include/hyperion/ImageToLedsMap.h index 17662f28..45e7bb5a 100644 --- a/include/hyperion/ImageToLedsMap.h +++ b/include/hyperion/ImageToLedsMap.h @@ -413,9 +413,13 @@ namespace hyperion } // Compute the average of each color channel - const uint8_t avgRed = uint8_t(std::min(std::lround(sqrt(static_cast(cummRed/pixelNum))), 255L)); - const uint8_t avgGreen = uint8_t(std::min(std::lround(sqrt(static_cast(cummGreen/pixelNum))), 255L)); - const uint8_t avgBlue = uint8_t(std::min(std::lround(sqrt(static_cast(cummBlue/pixelNum))), 255L)); + + #ifdef WIN32 + #undef min + #endif + const uint8_t avgRed = static_cast(std::min(std::lround(std::sqrt(static_cast(cummRed / pixelNum))), 255L)); + const uint8_t avgGreen = static_cast(std::min(std::lround(sqrt(static_cast(cummGreen / pixelNum))), 255L)); + const uint8_t avgBlue = static_cast(std::min(std::lround(sqrt(static_cast(cummBlue / pixelNum))), 255L)); // Return the computed color return {avgRed, avgGreen, avgBlue}; diff --git a/libsrc/api/JsonAPI.cpp b/libsrc/api/JsonAPI.cpp index 212dc14b..d3e401a9 100644 --- a/libsrc/api/JsonAPI.cpp +++ b/libsrc/api/JsonAPI.cpp @@ -404,7 +404,7 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject &message, const QString activePriorities.removeAll(PriorityMuxer::LOWEST_PRIORITY); int currentPriority = _hyperion->getCurrentPriority(); - for(int priority : qAsConst(activePriorities)) + for(int priority : std::as_const(activePriorities)) { const Hyperion::InputInfo &priorityInfo = _hyperion->getPriorityInfo(priority); @@ -1387,7 +1387,7 @@ void JsonAPI::handleAuthorizeCommand(const QJsonObject &message, const QString & if (API::getPendingTokenRequests(vec)) { QJsonArray arr; - for (const auto &entry : qAsConst(vec)) + for (const auto &entry : std::as_const(vec)) { QJsonObject obj; obj["comment"] = entry.comment; diff --git a/libsrc/api/JsonCB.cpp b/libsrc/api/JsonCB.cpp index 965abf37..e3c4b32a 100644 --- a/libsrc/api/JsonCB.cpp +++ b/libsrc/api/JsonCB.cpp @@ -199,7 +199,7 @@ void JsonCB::handlePriorityUpdate(int currentPriority, const PriorityMuxer::Inpu activePriorities.removeAll(PriorityMuxer::LOWEST_PRIORITY); - for (int priority : qAsConst(activePriorities)) { + for (int priority : std::as_const(activePriorities)) { const Hyperion::InputInfo& priorityInfo = activeInputs[priority]; diff --git a/libsrc/db/DBManager.cpp b/libsrc/db/DBManager.cpp index a8711c15..f4494967 100644 --- a/libsrc/db/DBManager.cpp +++ b/libsrc/db/DBManager.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #ifdef _WIN32 #include @@ -425,15 +426,15 @@ void DBManager::doAddBindValue(QSqlQuery& query, const QVariantList& variants) c auto t = variant.userType(); switch(t) { - case QVariant::UInt: - case QVariant::Int: - case QVariant::Bool: + case QMetaType::UInt: + case QMetaType::Int: + case QMetaType::Bool: query.addBindValue(variant.toInt()); break; - case QVariant::Double: + case QMetaType::Double: query.addBindValue(variant.toFloat()); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: query.addBindValue(variant.toByteArray()); break; default: diff --git a/libsrc/effectengine/EffectFileHandler.cpp b/libsrc/effectengine/EffectFileHandler.cpp index e1389e83..3d1c77eb 100644 --- a/libsrc/effectengine/EffectFileHandler.cpp +++ b/libsrc/effectengine/EffectFileHandler.cpp @@ -224,7 +224,7 @@ void EffectFileHandler::updateEffects() } QMap availableEffects; - for (const QString& path : qAsConst(efxPathList)) + for (const QString& path : std::as_const(efxPathList)) { QDir directory(path); if (!directory.exists()) @@ -241,8 +241,8 @@ void EffectFileHandler::updateEffects() else { int efxCount = 0; - QStringList filenames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase); - for (const QString& filename : qAsConst(filenames)) + const QStringList filenames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase); + for (const QString& filename : filenames) { EffectDefinition def; if (loadEffectDefinition(path, filename, def)) @@ -268,8 +268,8 @@ void EffectFileHandler::updateEffects() QString schemaPath = path + "schema" + '/'; directory.setPath(schemaPath); - QStringList schemaFileNames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase); - for (const QString& schemaFileName : qAsConst(schemaFileNames)) + const QStringList schemaFileNames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase); + for (const QString& schemaFileName : schemaFileNames) { EffectSchema pyEffect; if (loadEffectSchema(path, directory.filePath(schemaFileName), pyEffect)) @@ -282,7 +282,7 @@ void EffectFileHandler::updateEffects() } } - for (const auto& item : qAsConst(availableEffects)) + for (const auto& item : std::as_const(availableEffects)) { _availableEffects.push_back(item); } diff --git a/libsrc/forwarder/MessageForwarder.cpp b/libsrc/forwarder/MessageForwarder.cpp index b795cbe8..3720ad54 100644 --- a/libsrc/forwarder/MessageForwarder.cpp +++ b/libsrc/forwarder/MessageForwarder.cpp @@ -269,7 +269,7 @@ int MessageForwarder::startJsonTargets(const QJsonObject& config) if (!_jsonTargets.isEmpty()) { - for (const auto& targetHost : qAsConst(_jsonTargets)) + for (const auto& targetHost : std::as_const(_jsonTargets)) { Info(_log, "Forwarding now to JSON-target host: %s port: %u", QSTRING_CSTR(targetHost.host.toString()), targetHost.port); } @@ -286,7 +286,7 @@ void MessageForwarder::stopJsonTargets() if (!_jsonTargets.isEmpty()) { disconnect(_hyperion, &Hyperion::forwardJsonMessage, nullptr, nullptr); - for (const auto& targetHost : qAsConst(_jsonTargets)) + for (const auto& targetHost : std::as_const(_jsonTargets)) { Info(_log, "Stopped forwarding to JSON-target host: %s port: %u", QSTRING_CSTR(targetHost.host.toString()), targetHost.port); } @@ -373,7 +373,7 @@ int MessageForwarder::startFlatbufferTargets(const QJsonObject& config) if (!_flatbufferTargets.isEmpty()) { - for (const auto& targetHost : qAsConst(_flatbufferTargets)) + for (const auto& targetHost : std::as_const(_flatbufferTargets)) { Info(_log, "Forwarding now to Flatbuffer-target host: %s port: %u", QSTRING_CSTR(targetHost.host.toString()), targetHost.port); } @@ -399,7 +399,7 @@ void MessageForwarder::stopFlatbufferTargets() _messageForwarderFlatBufHelper = nullptr; } - for (const auto& targetHost : qAsConst(_flatbufferTargets)) + for (const auto& targetHost : std::as_const(_flatbufferTargets)) { Info(_log, "Stopped forwarding to Flatbuffer-target host: %s port: %u", QSTRING_CSTR(targetHost.host.toString()), targetHost.port); } @@ -412,7 +412,7 @@ void MessageForwarder::forwardJsonMessage(const QJsonObject& message) if (_forwarder_enabled) { QTcpSocket client; - for (const auto& targetHost : qAsConst(_jsonTargets)) + for (const auto& targetHost : std::as_const(_jsonTargets)) { client.connectToHost(targetHost.host, targetHost.port); if (client.waitForConnected(CONNECT_TIMEOUT.count())) diff --git a/libsrc/grabber/audio/AudioGrabberWindows.cpp b/libsrc/grabber/audio/AudioGrabberWindows.cpp index 07837bd1..ef5d5871 100644 --- a/libsrc/grabber/audio/AudioGrabberWindows.cpp +++ b/libsrc/grabber/audio/AudioGrabberWindows.cpp @@ -1,4 +1,7 @@ #include + +#include + #include #include #include @@ -61,7 +64,7 @@ bool AudioGrabberWindows::configureCaptureInterface() // wFormatTag, nChannels, nSamplesPerSec, mAvgBytesPerSec, // nBlockAlign, wBitsPerSample, cbSize - notificationSize = max(1024, audioFormat.nAvgBytesPerSec / 8); + notificationSize = std::max(static_cast(1024), static_cast(audioFormat.nAvgBytesPerSec / 8)); notificationSize -= notificationSize % audioFormat.nBlockAlign; bufferCaptureSize = notificationSize * AUDIO_NOTIFICATION_COUNT; diff --git a/libsrc/grabber/qt/QtGrabber.cpp b/libsrc/grabber/qt/QtGrabber.cpp index b3f35182..cb6e0c5c 100644 --- a/libsrc/grabber/qt/QtGrabber.cpp +++ b/libsrc/grabber/qt/QtGrabber.cpp @@ -103,7 +103,7 @@ bool QtGrabber::setupDisplay() Info(_log, "Available Displays:"); int index = 0; - for (auto* screen : qAsConst(screens)) + for (auto* screen : std::as_const(screens)) { const QRect geo = screen->geometry(); Info(_log, "Display %d: Name: %s Resolution: [%dx%d], Geometry: (L,T,R,B) %d,%d,%d,%d Depth:%dbit", index, QSTRING_CSTR(screen->name()), geo.width(), geo.height(), geo.x(), geo.y(), geo.x() + geo.width(), geo.y() + geo.height(), screen->depth()); diff --git a/libsrc/hyperion/ComponentRegister.cpp b/libsrc/hyperion/ComponentRegister.cpp index fd2f261d..9a040caf 100644 --- a/libsrc/hyperion/ComponentRegister.cpp +++ b/libsrc/hyperion/ComponentRegister.cpp @@ -61,7 +61,7 @@ ComponentRegister::ComponentRegister(Hyperion* hyperion) vect << COMP_FORWARDER; #endif - for(auto e : qAsConst(vect)) + for(auto e : std::as_const(vect)) { _componentStates.emplace(e, (e == COMP_ALL)); } diff --git a/libsrc/hyperion/SettingsManager.cpp b/libsrc/hyperion/SettingsManager.cpp index b9d78edc..b0b9675b 100644 --- a/libsrc/hyperion/SettingsManager.cpp +++ b/libsrc/hyperion/SettingsManager.cpp @@ -58,9 +58,9 @@ SettingsManager::SettingsManager(quint8 instance, QObject* parent, bool readonly } // transform json to string lists - QStringList keyList = defaultConfig.keys(); + const QStringList keyList = defaultConfig.keys(); QStringList defValueList; - for (const auto& key : qAsConst(keyList)) + for (const auto& key : keyList) { if (defaultConfig[key].isObject()) { @@ -73,7 +73,7 @@ SettingsManager::SettingsManager(quint8 instance, QObject* parent, bool readonly } // fill database with default data if required - for (const auto& key : qAsConst(keyList)) + for (const auto& key : keyList) { QString val = defValueList.takeFirst(); // prevent overwrite @@ -86,7 +86,7 @@ SettingsManager::SettingsManager(quint8 instance, QObject* parent, bool readonly // need to validate all data in database construct the entire data object // TODO refactor schemaChecker to accept QJsonArray in validate(); QJsonDocument container? To validate them per entry... QJsonObject dbConfig; - for (const auto& key : qAsConst(keyList)) + for (const auto& key : keyList) { QJsonDocument doc = _sTable->getSettingsRecord(key); if (doc.isArray()) @@ -242,9 +242,9 @@ bool SettingsManager::saveSettings(QJsonObject config, bool correct) _qconfig = config; // extract keys and data - QStringList keyList = config.keys(); + const QStringList keyList = config.keys(); QStringList newValueList; - for (const auto& key : qAsConst(keyList)) + for (const auto& key : keyList) { if (config[key].isObject()) { @@ -258,7 +258,7 @@ bool SettingsManager::saveSettings(QJsonObject config, bool correct) bool rc = true; // compare database data with new data to emit/save changes accordingly - for (const auto& key : qAsConst(keyList)) + for (const auto& key : keyList) { QString data = newValueList.takeFirst(); if (_sTable->getSettingsRecordString(key) != data) @@ -618,10 +618,10 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config) QJsonArray json; if (newForwarderConfig.contains("json")) { - QJsonArray oldJson = newForwarderConfig["json"].toArray(); + const QJsonArray oldJson = newForwarderConfig["json"].toArray(); QJsonObject newJsonConfig; - for (const QJsonValue& value : qAsConst(oldJson)) + for (const QJsonValue& value : oldJson) { if (value.isString()) { @@ -661,10 +661,10 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config) QJsonArray flatbuffer; if (newForwarderConfig.contains("flat")) { - QJsonArray oldFlatbuffer = newForwarderConfig["flat"].toArray(); + const QJsonArray oldFlatbuffer = newForwarderConfig["flat"].toArray(); QJsonObject newFlattbufferConfig; - for (const QJsonValue& value : qAsConst(oldFlatbuffer)) + for (const QJsonValue& value : oldFlatbuffer) { if (value.isString()) { diff --git a/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp b/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp index 8f73ae5f..ba008ab0 100644 --- a/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp +++ b/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp @@ -1126,7 +1126,7 @@ bool LedDevicePhilipsHue::setLights() if( !lArray.empty() ) { - for (const QJsonValue &id : qAsConst(lArray)) + for (const QJsonValue &id : std::as_const(lArray)) { int lightId = id.toString().toInt(); if( lightId > 0 ) diff --git a/libsrc/leddevice/dev_net/LedDeviceWled.cpp b/libsrc/leddevice/dev_net/LedDeviceWled.cpp index 3ada5091..e23a8c9b 100644 --- a/libsrc/leddevice/dev_net/LedDeviceWled.cpp +++ b/libsrc/leddevice/dev_net/LedDeviceWled.cpp @@ -352,12 +352,12 @@ bool LedDeviceWled::powerOn() } else { - QJsonArray propertiesSegments = _originalStateProperties[STATE_SEG].toArray(); + const QJsonArray propertiesSegments = _originalStateProperties[STATE_SEG].toArray(); bool isStreamSegmentIdFound { false }; QJsonArray segments; - for (const auto& segmentItem : qAsConst(propertiesSegments)) + for (const auto& segmentItem : propertiesSegments) { QJsonObject segmentObj = segmentItem.toObject(); @@ -505,9 +505,9 @@ bool LedDeviceWled::restoreState() if (_isStreamToSegment) { - QJsonArray propertiesSegments = _originalStateProperties[STATE_SEG].toArray(); + const QJsonArray propertiesSegments = _originalStateProperties[STATE_SEG].toArray(); QJsonArray segments; - for (const auto& segmentItem : qAsConst(propertiesSegments)) + for (const auto& segmentItem : propertiesSegments) { QJsonObject segmentObj = segmentItem.toObject(); diff --git a/libsrc/utils/Logger.cpp b/libsrc/utils/Logger.cpp index 86b4e903..b34981c9 100644 --- a/libsrc/utils/Logger.cpp +++ b/libsrc/utils/Logger.cpp @@ -65,7 +65,7 @@ void Logger::deleteInstance(const QString & name, const QString & subName) if (name.isEmpty()) { - for (auto *logger : qAsConst(LoggerMap)) { + for (auto *logger : std::as_const(LoggerMap)) { delete logger; } diff --git a/libsrc/utils/jsonschema/QJsonSchemaChecker.cpp b/libsrc/utils/jsonschema/QJsonSchemaChecker.cpp index 685ab4c7..8cd0be75 100644 --- a/libsrc/utils/jsonschema/QJsonSchemaChecker.cpp +++ b/libsrc/utils/jsonschema/QJsonSchemaChecker.cpp @@ -59,13 +59,13 @@ QPair QJsonSchemaChecker::validate(const QJsonObject& value, bool ig QJsonObject QJsonSchemaChecker::getAutoCorrectedConfig(const QJsonObject& value, bool ignoreRequired) { _ignoreRequired = ignoreRequired; - QStringList sequence = QStringList() << "remove" << "modify" << "create"; + const QStringList sequence = QStringList() << "remove" << "modify" << "create"; _error = false; _schemaError = false; _messages.clear(); _autoCorrected = value; - for (const QString& correct : qAsConst(sequence)) + for (const QString& correct : sequence) { _correct = correct; _currentPath.clear(); diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index f47fbb14..e7fdc453 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -57,9 +57,9 @@ void showHelp(Option & option){ int getInstaneIdbyName(const QJsonObject & reply, const QString & name){ if(reply.contains("instance")){ - QJsonArray list = reply.value("instance").toArray(); + const QJsonArray list = reply.value("instance").toArray(); - for ( const auto &entry : qAsConst(list) ) { + for ( const auto &entry : list ) { const QJsonObject obj = entry.toObject(); if(obj["friendly_name"] == name && obj["running"].toBool()) { diff --git a/src/hyperiond/main.cpp b/src/hyperiond/main.cpp index 4719cd22..fa9352b9 100644 --- a/src/hyperiond/main.cpp +++ b/src/hyperiond/main.cpp @@ -268,9 +268,9 @@ int main(int argc, char** argv) if (directory.exists() && destDir.exists()) { std::cout << "Extract to folder: " << destDir.absolutePath().toStdString() << std::endl; - QStringList filenames = directory.entryList(QStringList() << "*", QDir::Files, QDir::Name | QDir::IgnoreCase); + const QStringList filenames = directory.entryList(QStringList() << "*", QDir::Files, QDir::Name | QDir::IgnoreCase); QString destFileName; - for (const QString & filename : qAsConst(filenames)) + for (const QString & filename : filenames) { destFileName = destDir.dirName()+"/"+filename; if (QFile::exists(destFileName))