From 94da1308ac427ecad751c730f3ebb99ac4856235 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Wed, 25 Feb 2026 15:34:24 +0500 Subject: [PATCH 1/8] Refactor warning enabling, enable warnings-as-errors Signed-off-by: Octol1ttle --- CMakeLists.txt | 8 +- cmake/CompilerWarnings.cmake | 163 ----------------------------------- launcher/CMakeLists.txt | 28 +++--- 3 files changed, 19 insertions(+), 180 deletions(-) delete mode 100644 cmake/CompilerWarnings.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e452aee77..8cf036bbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,16 +35,12 @@ add_compile_definitions($<$>:QT_NO_DEBUG>) if(MSVC) # /GS Adds buffer security checks, default on but incuded anyway to mirror gcc's fstack-protector flag - # /permissive- specify standards-conforming compiler behavior, also enabled by Qt6, default on with std:c++20 - # Use /W4 as /Wall includes unnesserey warnings such as added padding to structs - set(CMAKE_CXX_FLAGS "/GS /permissive- /W4 ${CMAKE_CXX_FLAGS}") - # /EHs Enables stack unwind semantics for standard C++ exceptions to ensure stackframes are unwound # and object deconstructors are called when an exception is caught. # without it memory leaks and a warning is printed # /EHc tells the compiler to assume that functions declared as extern "C" never throw a C++ exception # This appears to not always be a defualt compiler option in CMAKE - set(CMAKE_CXX_FLAGS "/EHsc ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "/GS /EHsc ${CMAKE_CXX_FLAGS}") # LINK accepts /SUBSYSTEM whics sets if we are a WINDOWS (gui) or a CONSOLE programs # This implicitly selects an entrypoint specific to the subsystem selected @@ -79,7 +75,7 @@ if(MSVC) set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release "") endif() else() - set(CMAKE_CXX_FLAGS "-Wall -pedantic -fstack-protector-strong --param=ssp-buffer-size=4 ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "-fstack-protector-strong --param=ssp-buffer-size=4 ${CMAKE_CXX_FLAGS}") # ATL's pack list needs more than the default 1 Mib stack on windows if(WIN32) diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake deleted file mode 100644 index 51d2fb13a..000000000 --- a/cmake/CompilerWarnings.cmake +++ /dev/null @@ -1,163 +0,0 @@ -# -# Function to set compiler warnings with reasonable defaults at the project level. -# Taken from https://github.com/aminya/project_options/blob/main/src/CompilerWarnings.cmake -# under the folowing license: -# -# MIT License -# -# Copyright (c) 2022-2100 Amin Yahyaabadi -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -include_guard() - -function(_set_project_warnings_add_target_link_option TARGET OPTIONS) - target_link_options(${_project_name} INTERFACE ${OPTIONS}) -endfunction() - -# Set the compiler warnings -# -# https://clang.llvm.org/docs/DiagnosticsReference.html -# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md -function( - set_project_warnings - _project_name - MSVC_WARNINGS - CLANG_WARNINGS - GCC_WARNINGS -) - if("${MSVC_WARNINGS}" STREQUAL "") - set(MSVC_WARNINGS - /W4 # Baseline reasonable warnings - /w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss of data - /w14254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data - /w14263 # 'function': member function does not override any base class virtual member function - /w14265 # 'classname': class has virtual functions, but destructor is not virtual instances of this class may not - # be destructed correctly - /w14287 # 'operator': unsigned/negative constant mismatch - /we4289 # nonstandard extension used: 'variable': loop control variable declared in the for-loop is used outside - # the for-loop scope - /w14296 # 'operator': expression is always 'boolean_value' - /w14311 # 'variable': pointer truncation from 'type1' to 'type2' - /w14545 # expression before comma evaluates to a function which is missing an argument list - /w14546 # function call before comma missing argument list - /w14547 # 'operator': operator before comma has no effect; expected operator with side-effect - /w14549 # 'operator': operator before comma has no effect; did you intend 'operator'? - /w14555 # expression has no effect; expected expression with side- effect - /w14619 # pragma warning: there is no warning number 'number' - /w14640 # Enable warning on thread un-safe static member initialization - /w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may cause unexpected runtime behavior. - /w14905 # wide string literal cast to 'LPSTR' - /w14906 # string literal cast to 'LPWSTR' - /w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied - /permissive- # standards conformance mode for MSVC compiler. - - /we4062 # forbid omitting a possible value of an enum in a switch statement - ) - endif() - - if("${CLANG_WARNINGS}" STREQUAL "") - set(CLANG_WARNINGS - -Wall - -Wextra # reasonable and standard - -Wshadow # warn the user if a variable declaration shadows one from a parent context - -Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps - # catch hard to track down memory errors - -Wold-style-cast # warn for c-style casts - -Wcast-align # warn for potential performance problem casts - -Wunused # warn on anything being unused - -Woverloaded-virtual # warn if you overload (not override) a virtual function - -Wpedantic # warn if non-standard C++ is used - -Wconversion # warn on type conversions that may lose data - -Wsign-conversion # warn on sign conversions - -Wnull-dereference # warn if a null dereference is detected - -Wdouble-promotion # warn if float is implicit promoted to double - -Wformat=2 # warn on security issues around functions that format output (ie printf) - -Wimplicit-fallthrough # warn on statements that fallthrough without an explicit annotation - # -Wgnu-zero-variadic-macro-arguments (part of -pedantic) is triggered by every qCDebug() call and therefore results - # in a lot of noise. This warning is only notifying us that clang is emulating the GCC behaviour - # instead of the exact standard wording so we can safely ignore it - -Wno-gnu-zero-variadic-macro-arguments - - -Werror=switch # forbid omitting a possible value of an enum in a switch statement - ) - endif() - - if("${GCC_WARNINGS}" STREQUAL "") - set(GCC_WARNINGS - ${CLANG_WARNINGS} - -Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist - -Wduplicated-cond # warn if if / else chain has duplicated conditions - -Wduplicated-branches # warn if if / else branches have duplicated code - -Wlogical-op # warn about logical operations being used where bitwise were probably wanted - -Wuseless-cast # warn if you perform a cast to the same type - - -Werror=switch # forbid omitting a possible value of an enum in a switch statement - ) - endif() - - if(MSVC) - set(PROJECT_WARNINGS_CXX ${MSVC_WARNINGS}) - elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") - set(PROJECT_WARNINGS_CXX ${CLANG_WARNINGS}) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(PROJECT_WARNINGS_CXX ${GCC_WARNINGS}) - else() - message(AUTHOR_WARNING "No compiler warnings set for CXX compiler: '${CMAKE_CXX_COMPILER_ID}'") - # TODO support Intel compiler - endif() - - # Add C warnings - set(PROJECT_WARNINGS_C "${PROJECT_WARNINGS_CXX}") - list( - REMOVE_ITEM - PROJECT_WARNINGS_C - -Wnon-virtual-dtor - -Wold-style-cast - -Woverloaded-virtual - -Wuseless-cast - -Wextra-semi - - -Werror=switch # forbid omitting a possible value of an enum in a switch statement - ) - - target_compile_options( - ${_project_name} - INTERFACE # C++ warnings - $<$:${PROJECT_WARNINGS_CXX}> - # C warnings - $<$:${PROJECT_WARNINGS_C}> - ) - - # If we are using the compiler as a linker driver pass the warnings to it - # (most useful when using LTO or warnings as errors) - if(CMAKE_CXX_LINK_EXECUTABLE MATCHES "^") - _set_project_warnings_add_target_link_option( - ${_project_name} "$<$:${PROJECT_WARNINGS_CXX}>" - ) - endif() - - if(CMAKE_C_LINK_EXECUTABLE MATCHES "^") - _set_project_warnings_add_target_link_option( - ${_project_name} "$<$:${PROJECT_WARNINGS_C}>" - ) - endif() - - endfunction() diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index cc9233a85..4de4f5474 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -1319,7 +1319,13 @@ if(WIN32) set(LAUNCHER_RCS ${CMAKE_CURRENT_BINARY_DIR}/../${Launcher_Branding_WindowsRC}) endif() -include(CompilerWarnings) +function(enable_warnings TARGET) + if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + target_compile_options(${TARGET} PRIVATE /W4 /WX /permissive-) + else() + target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wpedantic -Werror) + endif() +endfunction() ######## Precompiled Headers ########### @@ -1336,13 +1342,17 @@ endif() # Add executable add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHER_UI} ${LAUNCHER_RESOURCES}) -set_project_warnings(Launcher_logic - "${Launcher_MSVC_WARNINGS}" - "${Launcher_CLANG_WARNINGS}" - "${Launcher_GCC_WARNINGS}") +enable_warnings(Launcher_logic) target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_definitions(Launcher_logic PUBLIC LAUNCHER_APPLICATION) +# Disable some warnings due to being present in a lot of places. TODO: Fix them. +if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + target_compile_options(Launcher_logic PRIVATE /wd4100) # C4100 - unused parameter +else() + target_compile_options(Launcher_logic PRIVATE -Wno-unused-parameter -Wno-missing-field-initializers) +endif() + if(${Launcher_USE_PCH}) target_precompile_headers(Launcher_logic PRIVATE ${PRECOMPILED_HEADERS}) endif() @@ -1424,8 +1434,6 @@ if(APPLE) endif() endif() -target_link_libraries(Launcher_logic) - add_executable(${Launcher_Name} MACOSX_BUNDLE WIN32 main.cpp ${LAUNCHER_RCS}) if(${Launcher_USE_PCH}) @@ -1462,6 +1470,7 @@ endif() if(Launcher_BUILD_UPDATER) # Updater add_library(prism_updater_logic STATIC ${PRISMUPDATER_SOURCES} ${TASKS_SOURCES} ${PRISMUPDATER_UI}) + enable_warnings(prism_updater_logic) target_include_directories(prism_updater_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) if(${Launcher_USE_PCH}) @@ -1514,10 +1523,7 @@ endif() if(WIN32 OR (DEFINED Launcher_BUILD_FILELINKER AND Launcher_BUILD_FILELINKER)) # File link add_library(filelink_logic STATIC ${LINKEXE_SOURCES}) - set_project_warnings(filelink_logic - "${Launcher_MSVC_WARNINGS}" - "${Launcher_CLANG_WARNINGS}" - "${Launcher_GCC_WARNINGS}") + enable_warnings(filelink_logic) target_include_directories(filelink_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) From ec4b36b29947af9dc169048b5dd519b685c70977 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Wed, 25 Feb 2026 15:37:20 +0500 Subject: [PATCH 2/8] Fix compiler warnings Signed-off-by: Octol1ttle --- launcher/Application.cpp | 2 +- launcher/FileSystem.cpp | 3 +++ launcher/InstanceList.cpp | 8 ++++---- launcher/InstanceList.h | 2 +- launcher/Json.cpp | 2 +- launcher/java/JavaInstall.cpp | 4 ++-- launcher/java/JavaMetadata.cpp | 4 ++-- launcher/minecraft/ComponentUpdateTask.cpp | 2 +- launcher/minecraft/ComponentUpdateTask.h | 2 +- launcher/minecraft/World.cpp | 4 ++-- launcher/minecraft/auth/MinecraftAccount.cpp | 12 ++++++------ launcher/minecraft/mod/ModFolderModel.cpp | 1 - .../minecraft/mod/tasks/LocalModParseTask.cpp | 17 +++++++---------- .../modplatform/flame/FlamePackExportTask.cpp | 8 ++++---- .../modplatform/flame/FlamePackExportTask.h | 2 +- .../modrinth/ModrinthCheckUpdate.cpp | 5 +---- launcher/ui/dialogs/skins/draw/BoxGeometry.cpp | 8 ++++---- launcher/ui/dialogs/skins/draw/Scene.cpp | 10 +++++----- .../ui/dialogs/skins/draw/SkinOpenGLWindow.cpp | 4 ++-- launcher/ui/instanceview/VisualGroup.cpp | 4 ++-- launcher/ui/pages/modplatform/ResourcePage.cpp | 5 ++--- launcher/ui/pages/modplatform/ftb/FtbPage.cpp | 12 ++++++------ launcher/ui/pages/modplatform/ftb/FtbPage.h | 4 ++-- launcher/ui/widgets/JavaWizardWidget.cpp | 3 --- .../updater/prismupdater/UpdaterDialogs.cpp | 4 ++-- 25 files changed, 62 insertions(+), 70 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 740141f9c..d39348e8d 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -392,7 +392,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) } else { QDir foo; if (DesktopServices::isSnap()) { - foo = QDir(getenv("SNAP_USER_COMMON")); + foo = QDir(qEnvironmentVariable("SNAP_USER_COMMON")); } else { foo = QDir(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "..")); } diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 9ca1c5fa6..5c328c75f 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -282,6 +282,9 @@ bool copyFileAttributes(QString src, QString dst) if (attrs == INVALID_FILE_ATTRIBUTES) return false; return SetFileAttributesW(dst.toStdWString().c_str(), attrs); +#else + Q_UNUSED(src); + Q_UNUSED(dst); #endif return true; } diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp index 1542886a1..c1123679f 100644 --- a/launcher/InstanceList.cpp +++ b/launcher/InstanceList.cpp @@ -153,13 +153,13 @@ QStringList InstanceList::getLinkedInstancesById(const QString& id) const int InstanceList::rowCount(const QModelIndex& parent) const { Q_UNUSED(parent); - return m_instances.size(); + return count(); } QModelIndex InstanceList::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); - if (row < 0 || static_cast(row) >= m_instances.size()) + if (row < 0 || row >= count()) return QModelIndex(); return createIndex(row, column, m_instances.at(row).get()); } @@ -579,7 +579,7 @@ void InstanceList::saveNow() void InstanceList::add(std::vector>& t) { - beginInsertRows(QModelIndex(), m_instances.size(), m_instances.size() + t.size() - 1); + beginInsertRows(QModelIndex(), count(), static_cast(count() + t.size() - 1)); for (auto& ptr : t) { m_instances.push_back(std::move(ptr)); connect(m_instances.back().get(), &BaseInstance::propertiesChanged, this, &InstanceList::propertiesChanged); @@ -644,7 +644,7 @@ QModelIndex InstanceList::getInstanceIndexById(const QString& id) const int InstanceList::getInstIndex(BaseInstance* inst) const { - int count = m_instances.size(); + int count = this->count(); for (int i = 0; i < count; i++) { if (inst == m_instances.at(i).get()) { return i; diff --git a/launcher/InstanceList.h b/launcher/InstanceList.h index d996e0865..64c950d08 100644 --- a/launcher/InstanceList.h +++ b/launcher/InstanceList.h @@ -98,7 +98,7 @@ class InstanceList : public QAbstractListModel { BaseInstance* at(int i) const { return m_instances.at(i).get(); } - int count() const { return m_instances.size(); } + qsizetype count() const { return static_cast(m_instances.size()); } InstListError loadList(); void saveNow(); diff --git a/launcher/Json.cpp b/launcher/Json.cpp index 688f9dae7..2d3372e2e 100644 --- a/launcher/Json.cpp +++ b/launcher/Json.cpp @@ -303,7 +303,7 @@ QStringList toStringList(const QString& jsonString) return {}; try { return requireIsArrayOf(doc); - } catch (Json::JsonException& e) { + } catch (Json::JsonException&) { return {}; } } diff --git a/launcher/java/JavaInstall.cpp b/launcher/java/JavaInstall.cpp index 30cb77e08..98aac5cab 100644 --- a/launcher/java/JavaInstall.cpp +++ b/launcher/java/JavaInstall.cpp @@ -49,7 +49,7 @@ bool JavaInstall::operator<(BaseVersion& a) const { try { return operator<(dynamic_cast(a)); - } catch (const std::bad_cast& e) { + } catch (const std::bad_cast&) { return BaseVersion::operator<(a); } } @@ -58,7 +58,7 @@ bool JavaInstall::operator>(BaseVersion& a) const { try { return operator>(dynamic_cast(a)); - } catch (const std::bad_cast& e) { + } catch (const std::bad_cast&) { return BaseVersion::operator>(a); } } diff --git a/launcher/java/JavaMetadata.cpp b/launcher/java/JavaMetadata.cpp index 115baa9e5..3647c963f 100644 --- a/launcher/java/JavaMetadata.cpp +++ b/launcher/java/JavaMetadata.cpp @@ -111,7 +111,7 @@ bool Metadata::operator<(BaseVersion& a) const { try { return operator<(dynamic_cast(a)); - } catch (const std::bad_cast& e) { + } catch (const std::bad_cast&) { return BaseVersion::operator<(a); } } @@ -120,7 +120,7 @@ bool Metadata::operator>(BaseVersion& a) const { try { return operator>(dynamic_cast(a)); - } catch (const std::bad_cast& e) { + } catch (const std::bad_cast&) { return BaseVersion::operator>(a); } } diff --git a/launcher/minecraft/ComponentUpdateTask.cpp b/launcher/minecraft/ComponentUpdateTask.cpp index d392ddb7e..ceae10dbe 100644 --- a/launcher/minecraft/ComponentUpdateTask.cpp +++ b/launcher/minecraft/ComponentUpdateTask.cpp @@ -223,7 +223,7 @@ void ComponentUpdateTask::loadComponents() componentIndex++; } d->remoteTasksInProgress = taskIndex; - m_progressTotal = taskIndex; + m_progressTotal = static_cast(taskIndex); switch (result) { case LoadResult::LoadedLocal: { // Everything got loaded. Advance to dependency resolution. diff --git a/launcher/minecraft/ComponentUpdateTask.h b/launcher/minecraft/ComponentUpdateTask.h index c4c3fd3cc..b0a6f8bff 100644 --- a/launcher/minecraft/ComponentUpdateTask.h +++ b/launcher/minecraft/ComponentUpdateTask.h @@ -21,7 +21,7 @@ class ComponentUpdateTask : public Task { bool abort() override; protected: - void executeTask(); + void executeTask() override; private: void loadComponents(); diff --git a/launcher/minecraft/World.cpp b/launcher/minecraft/World.cpp index a365eafc3..f58e24b06 100644 --- a/launcher/minecraft/World.cpp +++ b/launcher/minecraft/World.cpp @@ -256,7 +256,7 @@ void World::readFromFS(const QFileInfo& file) loadFromLevelDat(bytes); m_levelDatTime = file.lastModified(); if (m_randomSeed == 0) { - auto bytes = getWorldGenDataFromFS(file); + bytes = getWorldGenDataFromFS(file); if (!bytes.isEmpty()) { m_randomSeed = loadSeed(bytes); } @@ -426,7 +426,7 @@ int64_t loadSeed(QByteArray data) nbt::value* valPtr = nullptr; try { valPtr = &levelData->at("data"); - } catch (const std::out_of_range& e) { + } catch (const std::out_of_range&) { return 0; } nbt::value& val = *valPtr; diff --git a/launcher/minecraft/auth/MinecraftAccount.cpp b/launcher/minecraft/auth/MinecraftAccount.cpp index 1592a22d2..065273268 100644 --- a/launcher/minecraft/auth/MinecraftAccount.cpp +++ b/launcher/minecraft/auth/MinecraftAccount.cpp @@ -278,12 +278,12 @@ QUuid MinecraftAccount::uuidFromUsername(QString username) // basically a reimplementation of Java's UUID#nameUUIDFromBytes QByteArray digest = QCryptographicHash::hash(input, QCryptographicHash::Md5); - auto bOr = [](QByteArray& array, qsizetype index, char value) { array[index] |= value; }; - auto bAnd = [](QByteArray& array, qsizetype index, char value) { array[index] &= value; }; - bAnd(digest, 6, (char)0x0f); // clear version - bOr(digest, 6, (char)0x30); // set to version 3 - bAnd(digest, 8, (char)0x3f); // clear variant - bOr(digest, 8, (char)0x80); // set to IETF variant + auto bOr = [](QByteArray& array, qsizetype index, uint8_t value) { array[index] |= value; }; + auto bAnd = [](QByteArray& array, qsizetype index, uint8_t value) { array[index] &= value; }; + bAnd(digest, 6, 0x0f); // clear version + bOr(digest, 6, 0x30); // set to version 3 + bAnd(digest, 8, 0x3f); // clear variant + bOr(digest, 8, 0x80); // set to IETF variant return QUuid::fromRfc4122(digest); } diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index 50b8985c8..4d54be921 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -219,7 +219,6 @@ QVariant ModFolderModel::headerData(int section, [[maybe_unused]] Qt::Orientatio default: return QVariant(); } - return QVariant(); } int ModFolderModel::columnCount(const QModelIndex& parent) const diff --git a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp index c0807907b..5f3e43216 100644 --- a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp @@ -263,12 +263,11 @@ ModDetails ReadMCModTOML(QByteArray contents) } else if (auto depTable = depValue.as_table()) { auto expectedKey = details.mod_id.toStdString(); if (!depTable->contains(expectedKey)) { - for (auto [k, v] : *depTable) { - expectedKey = k; - break; + if (auto it = depTable->begin(); it != depTable->end()) { + expectedKey = it->first; } } - if (auto array = (*depTable)[expectedKey].as_array()) { + if ((array = (*depTable)[expectedKey].as_array())) { parseDep(array); } } @@ -352,9 +351,8 @@ ModDetails ReadFabricModInfo(QByteArray contents) details.icon_file = obj.value(key).toString(); } else { // parsing the sizes failed // take the first - for (auto i : obj) { - details.icon_file = i.toString(); - break; + if (auto it = obj.begin(); it != obj.end()) { + details.icon_file = it->toString(); } } } else if (icon.isString()) { @@ -451,9 +449,8 @@ ModDetails ReadQuiltModInfo(QByteArray contents) details.icon_file = obj.value(key).toString(); } else { // parsing the sizes failed // take the first - for (auto i : obj) { - details.icon_file = i.toString(); - break; + if (auto it = obj.begin(); it != obj.end()) { + details.icon_file = it->toString(); } } } else if (icon.isString()) { diff --git a/launcher/modplatform/flame/FlamePackExportTask.cpp b/launcher/modplatform/flame/FlamePackExportTask.cpp index 37c9380f5..dffd13e27 100644 --- a/launcher/modplatform/flame/FlamePackExportTask.cpp +++ b/launcher/modplatform/flame/FlamePackExportTask.cpp @@ -67,8 +67,8 @@ void FlamePackExportTask::collectFiles() setAbortable(false); QCoreApplication::processEvents(); - files.clear(); - if (!MMCZip::collectFileListRecursively(m_options.instance->gameRoot(), nullptr, &files, m_options.filter)) { + m_files.clear(); + if (!MMCZip::collectFileListRecursively(m_options.instance->gameRoot(), nullptr, &m_files, m_options.filter)) { emitFailed(tr("Could not search for files")); return; } @@ -88,7 +88,7 @@ void FlamePackExportTask::collectHashes() auto allMods = m_options.instance->loaderModList()->allMods(); ConcurrentTask::Ptr hashingTask(new ConcurrentTask("MakeHashesTask", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt())); task.reset(hashingTask); - for (const QFileInfo& file : files) { + for (const QFileInfo& file : m_files) { const QString relative = m_gameRoot.relativeFilePath(file.absoluteFilePath()); // require sensible file types if (!std::any_of(FILE_EXTENSIONS.begin(), FILE_EXTENSIONS.end(), [&relative](const QString& extension) { @@ -319,7 +319,7 @@ void FlamePackExportTask::buildZip() setStatus(tr("Adding files...")); setProgress(4, 5); - auto zipTask = makeShared(m_options.output, m_gameRoot, files, "overrides/", true); + auto zipTask = makeShared(m_options.output, m_gameRoot, m_files, "overrides/", true); zipTask->addExtraFile("manifest.json", generateIndex()); zipTask->addExtraFile("modlist.html", generateHTML()); diff --git a/launcher/modplatform/flame/FlamePackExportTask.h b/launcher/modplatform/flame/FlamePackExportTask.h index f47041704..f6a90241d 100644 --- a/launcher/modplatform/flame/FlamePackExportTask.h +++ b/launcher/modplatform/flame/FlamePackExportTask.h @@ -72,7 +72,7 @@ class FlamePackExportTask : public Task { FlameAPI api; - QFileInfoList files; + QFileInfoList m_files; QMap pendingHashes{}; QMap resolvedFiles{}; Task::Ptr task; diff --git a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp index 35910338f..8d47bada7 100644 --- a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp +++ b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp @@ -152,10 +152,7 @@ void ModrinthCheckUpdate::checkVersionsResponse(QByteArray* response, std::optio // so we may want to filter it QString loader_filter; if (loader.has_value()) { - for (auto flag : ModPlatform::modLoaderTypesToList(*loader)) { - loader_filter = ModPlatform::getModLoaderAsString(flag); - break; - } + loader_filter = ModPlatform::getModLoaderAsString(ModPlatform::modLoaderTypesToList(*loader).first()); } // Currently, we rely on a couple heuristics to determine whether an update is actually available or not: diff --git a/launcher/ui/dialogs/skins/draw/BoxGeometry.cpp b/launcher/ui/dialogs/skins/draw/BoxGeometry.cpp index 4404442a4..f1f771303 100644 --- a/launcher/ui/dialogs/skins/draw/BoxGeometry.cpp +++ b/launcher/ui/dialogs/skins/draw/BoxGeometry.cpp @@ -247,11 +247,11 @@ void BoxGeometry::initGeometry(float u, float v, float width, float height, floa // Transfer vertex data to VBO 0 m_vertexBuf.bind(); - m_vertexBuf.allocate(verticesData.constData(), verticesData.size() * sizeof(VertexData)); + m_vertexBuf.allocate(verticesData.constData(), static_cast(verticesData.size() * sizeof(VertexData))); // Transfer index data to VBO 1 m_indexBuf.bind(); - m_indexBuf.allocate(indices.constData(), indices.size() * sizeof(GLushort)); + m_indexBuf.allocate(indices.constData(), static_cast(indices.size() * sizeof(GLushort))); m_indecesCount = indices.size(); } @@ -266,11 +266,11 @@ BoxGeometry* BoxGeometry::Plane() // Transfer vertex data to VBO 0 b->m_vertexBuf.bind(); - b->m_vertexBuf.allocate(planeVertices.constData(), planeVertices.size() * sizeof(VertexData)); + b->m_vertexBuf.allocate(planeVertices.constData(), static_cast(planeVertices.size() * sizeof(VertexData))); // Transfer index data to VBO 1 b->m_indexBuf.bind(); - b->m_indexBuf.allocate(planeIndices.constData(), planeIndices.size() * sizeof(GLushort)); + b->m_indexBuf.allocate(planeIndices.constData(), static_cast(planeIndices.size() * sizeof(GLushort))); b->m_indecesCount = planeIndices.size(); return b; diff --git a/launcher/ui/dialogs/skins/draw/Scene.cpp b/launcher/ui/dialogs/skins/draw/Scene.cpp index e8ede8c24..1d06c694f 100644 --- a/launcher/ui/dialogs/skins/draw/Scene.cpp +++ b/launcher/ui/dialogs/skins/draw/Scene.cpp @@ -34,9 +34,9 @@ Scene::Scene(const QImage& skin, bool slim, const QImage& cape) : QOpenGLFunctio // body new opengl::BoxGeometry(QVector3D(8, 12, 4), QVector3D(0, -6, 0), QPoint(16, 16), QVector3D(8, 12, 4)), // right leg - new opengl::BoxGeometry(QVector3D(4, 12, 4), QVector3D(-1.9, -18, -0.1), QPoint(0, 16), QVector3D(4, 12, 4)), + new opengl::BoxGeometry(QVector3D(4, 12, 4), QVector3D(-1.9f, -18, -0.1f), QPoint(0, 16), QVector3D(4, 12, 4)), // left leg - new opengl::BoxGeometry(QVector3D(4, 12, 4), QVector3D(1.9, -18, -0.1), QPoint(16, 48), QVector3D(4, 12, 4)), + new opengl::BoxGeometry(QVector3D(4, 12, 4), QVector3D(1.9f, -18, -0.1f), QPoint(16, 48), QVector3D(4, 12, 4)), }; m_staticComponentsOverlay = { @@ -45,9 +45,9 @@ Scene::Scene(const QImage& skin, bool slim, const QImage& cape) : QOpenGLFunctio // body new opengl::BoxGeometry(QVector3D(8.5, 12.5, 4.5), QVector3D(0, -6, 0), QPoint(16, 32), QVector3D(8, 12, 4)), // right leg - new opengl::BoxGeometry(QVector3D(4.5, 12.5, 4.5), QVector3D(-1.9, -18, -0.1), QPoint(0, 32), QVector3D(4, 12, 4)), + new opengl::BoxGeometry(QVector3D(4.5f, 12.5f, 4.5f), QVector3D(-1.9f, -18, -0.1f), QPoint(0, 32), QVector3D(4, 12, 4)), // left leg - new opengl::BoxGeometry(QVector3D(4.5, 12.5, 4.5), QVector3D(1.9, -18, -0.1), QPoint(0, 48), QVector3D(4, 12, 4)), + new opengl::BoxGeometry(QVector3D(4.5f, 12.5f, 4.5f), QVector3D(1.9f, -18, -0.1f), QPoint(0, 48), QVector3D(4, 12, 4)), }; m_normalArms = { @@ -79,7 +79,7 @@ Scene::Scene(const QImage& skin, bool slim, const QImage& cape) : QOpenGLFunctio }; m_cape = new opengl::BoxGeometry(QVector3D(10, 16, 1), QVector3D(0, -8, 2.5), QPoint(0, 0), QVector3D(10, 16, 1), QSize(64, 32)); - m_cape->rotate(10.8, QVector3D(1, 0, 0)); + m_cape->rotate(10.8f, QVector3D(1, 0, 0)); m_cape->rotate(180, QVector3D(0, 1, 0)); auto leftWing = diff --git a/launcher/ui/dialogs/skins/draw/SkinOpenGLWindow.cpp b/launcher/ui/dialogs/skins/draw/SkinOpenGLWindow.cpp index 03f10be1e..52799a7b9 100644 --- a/launcher/ui/dialogs/skins/draw/SkinOpenGLWindow.cpp +++ b/launcher/ui/dialogs/skins/draw/SkinOpenGLWindow.cpp @@ -270,10 +270,10 @@ QColor calculateContrastingColor(const QColor& color) { auto luma = Rainbow::luma(color); if (luma < 0.5) { - constexpr float contrast = 0.05; + constexpr float contrast = 0.05f; return Rainbow::lighten(color, contrast); } else { - constexpr float contrast = 0.2; + constexpr float contrast = 0.2f; return Rainbow::darken(color, contrast); } } diff --git a/launcher/ui/instanceview/VisualGroup.cpp b/launcher/ui/instanceview/VisualGroup.cpp index 4f7a61eb5..b68c09171 100644 --- a/launcher/ui/instanceview/VisualGroup.cpp +++ b/launcher/ui/instanceview/VisualGroup.cpp @@ -151,7 +151,7 @@ void VisualGroup::drawHeader(QPainter* painter, const QStyleOptionViewItem& opti QPen pen; pen.setWidth(2); QColor penColor = option.palette.text().color(); - penColor.setAlphaF(0.6); + penColor.setAlphaF(0.6f); pen.setColor(penColor); painter->setPen(pen); painter->setRenderHint(QPainter::Antialiasing); @@ -194,7 +194,7 @@ void VisualGroup::drawHeader(QPainter* painter, const QStyleOptionViewItem& opti // BEGIN: horizontal line { - penColor.setAlphaF(0.05); + penColor.setAlphaF(0.05f); pen.setColor(penColor); painter->setPen(pen); // startPoint is left + arrow + text + space diff --git a/launcher/ui/pages/modplatform/ResourcePage.cpp b/launcher/ui/pages/modplatform/ResourcePage.cpp index c1eed81bd..98aa650e0 100644 --- a/launcher/ui/pages/modplatform/ResourcePage.cpp +++ b/launcher/ui/pages/modplatform/ResourcePage.cpp @@ -557,9 +557,8 @@ void ResourcePage::openProject(QVariant projectID) [this, okBtn](int index) { okBtn->setEnabled(m_ui->versionSelectionBox->itemData(index).toInt() >= 0); }); auto jump = [this] { - for (int row = 0; row < m_model->rowCount({}); row++) { - const QModelIndex index = m_model->index(row); - m_ui->packView->setCurrentIndex(index); + if (m_model->rowCount({}) > 0) { + m_ui->packView->setCurrentIndex(m_model->index(0)); return; } m_ui->packDescription->setText(tr("The resource was not found")); diff --git a/launcher/ui/pages/modplatform/ftb/FtbPage.cpp b/launcher/ui/pages/modplatform/ftb/FtbPage.cpp index 216625101..b208f5c74 100644 --- a/launcher/ui/pages/modplatform/ftb/FtbPage.cpp +++ b/launcher/ui/pages/modplatform/ftb/FtbPage.cpp @@ -146,13 +146,13 @@ void FtbPage::triggerSearch() m_filterModel->setSearchTerm(m_ui->searchEdit->text()); } -void FtbPage::onSortingSelectionChanged(QString data) +void FtbPage::onSortingSelectionChanged(QString selected) { - auto toSet = m_filterModel->getAvailableSortings().value(data); + auto toSet = m_filterModel->getAvailableSortings().value(selected); m_filterModel->setSorting(toSet); } -void FtbPage::onSelectionChanged(QModelIndex first, QModelIndex second) +void FtbPage::onSelectionChanged(QModelIndex first, QModelIndex /*second*/) { m_ui->versionSelectionBox->clear(); @@ -176,14 +176,14 @@ void FtbPage::onSelectionChanged(QModelIndex first, QModelIndex second) suggestCurrent(); } -void FtbPage::onVersionSelectionChanged(QString data) +void FtbPage::onVersionSelectionChanged(QString selected) { - if (data.isNull() || data.isEmpty()) { + if (selected.isNull() || selected.isEmpty()) { m_selectedVersion = ""; return; } - m_selectedVersion = data; + m_selectedVersion = selected; suggestCurrent(); } diff --git a/launcher/ui/pages/modplatform/ftb/FtbPage.h b/launcher/ui/pages/modplatform/ftb/FtbPage.h index d85053fab..84e7740d4 100644 --- a/launcher/ui/pages/modplatform/ftb/FtbPage.h +++ b/launcher/ui/pages/modplatform/ftb/FtbPage.h @@ -80,9 +80,9 @@ class FtbPage : public QWidget, public ModpackProviderBasePage { private slots: void triggerSearch(); - void onSortingSelectionChanged(QString data); + void onSortingSelectionChanged(QString selected); void onSelectionChanged(QModelIndex first, QModelIndex second); - void onVersionSelectionChanged(QString data); + void onVersionSelectionChanged(QString selected); private: Ui::FtbPage* m_ui = nullptr; diff --git a/launcher/ui/widgets/JavaWizardWidget.cpp b/launcher/ui/widgets/JavaWizardWidget.cpp index c247b7882..3192c22ec 100644 --- a/launcher/ui/widgets/JavaWizardWidget.cpp +++ b/launcher/ui/widgets/JavaWizardWidget.cpp @@ -261,9 +261,6 @@ JavaWizardWidget::ValidationStatus JavaWizardWidget::validate() default: return ValidationStatus::Bad; } - if (button == QMessageBox::No) { - return ValidationStatus::Bad; - } } return ValidationStatus::JavaBad; } break; diff --git a/launcher/updater/prismupdater/UpdaterDialogs.cpp b/launcher/updater/prismupdater/UpdaterDialogs.cpp index eab3e6bbb..31e1b10aa 100644 --- a/launcher/updater/prismupdater/UpdaterDialogs.cpp +++ b/launcher/updater/prismupdater/UpdaterDialogs.cpp @@ -95,7 +95,7 @@ GitHubRelease SelectReleaseDialog::getRelease(QTreeWidgetItem* item) return release; } -void SelectReleaseDialog::selectionChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous) +void SelectReleaseDialog::selectionChanged(QTreeWidgetItem* current, QTreeWidgetItem* /*previous*/) { GitHubRelease release = getRelease(current); QString body = markdownToHTML(release.body.toUtf8()); @@ -166,7 +166,7 @@ GitHubReleaseAsset SelectReleaseAssetDialog::getAsset(QTreeWidgetItem* item) return selected_asset; } -void SelectReleaseAssetDialog::selectionChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous) +void SelectReleaseAssetDialog::selectionChanged(QTreeWidgetItem* current, QTreeWidgetItem* /*previous*/) { GitHubReleaseAsset asset = getAsset(current); m_selectedAsset = asset; From 110d1a8fcfbcbb18c7528ab68ab829a6505c3e63 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Wed, 25 Feb 2026 15:44:34 +0500 Subject: [PATCH 3/8] Update libnbtplusplus Signed-off-by: Octol1ttle --- libraries/libnbtplusplus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/libnbtplusplus b/libraries/libnbtplusplus index 531449ba1..353893361 160000 --- a/libraries/libnbtplusplus +++ b/libraries/libnbtplusplus @@ -1 +1 @@ -Subproject commit 531449ba1c930c98e0bcf5d332b237a8566f9d78 +Subproject commit 3538933614059f0f44388a2b16f3db25ce42285b From eda4592f191427ed6650139847f30fc7cf930de0 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Wed, 25 Feb 2026 16:22:49 +0500 Subject: [PATCH 4/8] Fix implicit fallthrough Signed-off-by: Octol1ttle --- launcher/GZip.cpp | 3 ++- launcher/VersionProxyModel.cpp | 3 +-- .../minecraft/mod/ResourcePackFolderModel.cpp | 26 +++++++++---------- .../modplatform/legacy_ftb/ListModel.cpp | 1 + launcher/ui/widgets/JavaWizardWidget.cpp | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/launcher/GZip.cpp b/launcher/GZip.cpp index dc786e10e..201dcd572 100644 --- a/launcher/GZip.cpp +++ b/launcher/GZip.cpp @@ -172,7 +172,8 @@ int inf(QFile* source, std::function handleBlock) assert(ret != Z_STREAM_ERROR); /* state not clobbered */ switch (ret) { case Z_NEED_DICT: - ret = Z_DATA_ERROR; /* and fall through */ + ret = Z_DATA_ERROR; + [[fallthrough]]; case Z_DATA_ERROR: case Z_MEM_ERROR: (void)inflateEnd(&strm); diff --git a/launcher/VersionProxyModel.cpp b/launcher/VersionProxyModel.cpp index 32048db8e..aaab7e8e0 100644 --- a/launcher/VersionProxyModel.cpp +++ b/launcher/VersionProxyModel.cpp @@ -198,9 +198,8 @@ QVariant VersionProxyModel::data(const QModelIndex& index, int role) const return tr("Latest"); } } - } else { - return sourceModel()->data(parentIndex, BaseVersionList::VersionIdRole); } + return sourceModel()->data(parentIndex, BaseVersionList::VersionIdRole); } case Qt::DecorationRole: { if (column == Name && hasRecommended) { diff --git a/launcher/minecraft/mod/ResourcePackFolderModel.cpp b/launcher/minecraft/mod/ResourcePackFolderModel.cpp index fd59d5765..68533945f 100644 --- a/launcher/minecraft/mod/ResourcePackFolderModel.cpp +++ b/launcher/minecraft/mod/ResourcePackFolderModel.cpp @@ -67,22 +67,22 @@ QVariant ResourcePackFolderModel::data(const QModelIndex& index, int role) const switch (role) { case Qt::BackgroundRole: return rowBackground(row); - case Qt::DisplayRole: - switch (column) { - case PackFormatColumn: { - auto& resource = at(row); - auto pack_format = resource.packFormat(); - if (pack_format == 0) - return tr("Unrecognized"); + case Qt::DisplayRole: { + if (column == PackFormatColumn) { + auto& resource = at(row); + auto pack_format = resource.packFormat(); + if (pack_format == 0) + return tr("Unrecognized"); - auto version_bounds = resource.compatibleVersions(); - if (version_bounds.first.toString().isEmpty()) - return QString::number(pack_format); + auto version_bounds = resource.compatibleVersions(); + if (version_bounds.first.toString().isEmpty()) + return QString::number(pack_format); - return QString("%1 (%2 - %3)") - .arg(QString::number(pack_format), version_bounds.first.toString(), version_bounds.second.toString()); - } + return QString("%1 (%2 - %3)") + .arg(QString::number(pack_format), version_bounds.first.toString(), version_bounds.second.toString()); } + break; + } case Qt::DecorationRole: { if (column == ImageColumn) { return at(row).image({ 32, 32 }, Qt::AspectRatioMode::KeepAspectRatioByExpanding); diff --git a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp index a11d87507..ab2bc6a67 100644 --- a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp +++ b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp @@ -192,6 +192,7 @@ QVariant ListModel::data(const QModelIndex& index, int role) const // bugged pack, currently only indicates bugged xml return QColor(244, 229, 66); } + return {}; } case Qt::DisplayRole: return pack.name; diff --git a/launcher/ui/widgets/JavaWizardWidget.cpp b/launcher/ui/widgets/JavaWizardWidget.cpp index 3192c22ec..086ca9481 100644 --- a/launcher/ui/widgets/JavaWizardWidget.cpp +++ b/launcher/ui/widgets/JavaWizardWidget.cpp @@ -255,7 +255,7 @@ JavaWizardWidget::ValidationStatus JavaWizardWidget::validate() return ValidationStatus::JavaBad; case QMessageBox::Help: DesktopServices::openUrl(QUrl(BuildConfig.HELP_URL.arg("java-wizard"))); - /* fallthrough */ + [[fallthrough]]; case QMessageBox::No: /* fallthrough */ default: From f26a4f897c5f6195fd60679a028c451870743094 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Wed, 25 Feb 2026 16:44:30 +0500 Subject: [PATCH 5/8] fix ignoring return value of function declared with 'nodiscard' attribute Signed-off-by: Octol1ttle --- launcher/FileSystem.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 5c328c75f..b7125a162 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -953,7 +953,10 @@ QString createShortcut(QString destination, QString target, QStringList args, QS qWarning() << "Couldn't create directories within application"; return QString(); } - info.open(QIODevice::WriteOnly | QIODevice::Text); + if (!info.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning() << "Failed to open file" << info.fileName() << "for writing!"; + return QString(); + } QFile(icon).rename(resources.path() + "/Icon.icns"); @@ -961,7 +964,10 @@ QString createShortcut(QString destination, QString target, QStringList args, QS QString exec = binaryDir.path() + "/Run.command"; QFile f(exec); - f.open(QIODevice::WriteOnly | QIODevice::Text); + if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning() << "Failed to open file" << f.fileName() << "for writing!"; + return QString(); + } QTextStream stream(&f); auto argstring = quoteArgs(args, "\"", "\\\""); From 9cf9ec534161ef069d74e09b8a4a5762e1760cb7 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Wed, 25 Feb 2026 19:50:09 +0500 Subject: [PATCH 6/8] fix(InstanceList): count() should be int as all usages expect int Signed-off-by: Octol1ttle --- launcher/InstanceList.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/InstanceList.h b/launcher/InstanceList.h index 64c950d08..f0a92d273 100644 --- a/launcher/InstanceList.h +++ b/launcher/InstanceList.h @@ -98,7 +98,7 @@ class InstanceList : public QAbstractListModel { BaseInstance* at(int i) const { return m_instances.at(i).get(); } - qsizetype count() const { return static_cast(m_instances.size()); } + int count() const { return static_cast(m_instances.size()); } InstListError loadList(); void saveNow(); From 0dfb6c99e1bc30ee2ebec6efc91f6b3453bcedcd Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Wed, 25 Feb 2026 22:17:52 +0500 Subject: [PATCH 7/8] fix(ModrinthCheckUpdate): guard list access Signed-off-by: Octol1ttle --- launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp index 8d47bada7..72769d231 100644 --- a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp +++ b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp @@ -151,7 +151,7 @@ void ModrinthCheckUpdate::checkVersionsResponse(QByteArray* response, std::optio // Sometimes a version may have multiple files, one with "forge" and one with "fabric", // so we may want to filter it QString loader_filter; - if (loader.has_value()) { + if (loader.has_value() && loader != 0) { loader_filter = ModPlatform::getModLoaderAsString(ModPlatform::modLoaderTypesToList(*loader).first()); } From 068bbba570e192139c287c7934b1ab6ef2dad037 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Thu, 5 Mar 2026 18:16:55 +0500 Subject: [PATCH 8/8] change: use BUILDSYSTEM_TARGETS to apply warnings Co-authored-by: Seth Flynn Signed-off-by: Octol1ttle --- launcher/CMakeLists.txt | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 4de4f5474..133016978 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -1319,14 +1319,6 @@ if(WIN32) set(LAUNCHER_RCS ${CMAKE_CURRENT_BINARY_DIR}/../${Launcher_Branding_WindowsRC}) endif() -function(enable_warnings TARGET) - if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") - target_compile_options(${TARGET} PRIVATE /W4 /WX /permissive-) - else() - target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wpedantic -Werror) - endif() -endfunction() - ######## Precompiled Headers ########### if(${Launcher_USE_PCH}) @@ -1342,17 +1334,9 @@ endif() # Add executable add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHER_UI} ${LAUNCHER_RESOURCES}) -enable_warnings(Launcher_logic) target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_definitions(Launcher_logic PUBLIC LAUNCHER_APPLICATION) -# Disable some warnings due to being present in a lot of places. TODO: Fix them. -if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") - target_compile_options(Launcher_logic PRIVATE /wd4100) # C4100 - unused parameter -else() - target_compile_options(Launcher_logic PRIVATE -Wno-unused-parameter -Wno-missing-field-initializers) -endif() - if(${Launcher_USE_PCH}) target_precompile_headers(Launcher_logic PRIVATE ${PRECOMPILED_HEADERS}) endif() @@ -1470,7 +1454,6 @@ endif() if(Launcher_BUILD_UPDATER) # Updater add_library(prism_updater_logic STATIC ${PRISMUPDATER_SOURCES} ${TASKS_SOURCES} ${PRISMUPDATER_UI}) - enable_warnings(prism_updater_logic) target_include_directories(prism_updater_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) if(${Launcher_USE_PCH}) @@ -1523,7 +1506,6 @@ endif() if(WIN32 OR (DEFINED Launcher_BUILD_FILELINKER AND Launcher_BUILD_FILELINKER)) # File link add_library(filelink_logic STATIC ${LINKEXE_SOURCES}) - enable_warnings(filelink_logic) target_include_directories(filelink_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) @@ -1583,6 +1565,26 @@ if (UNIX AND APPLE AND Launcher_ENABLE_UPDATER) install(DIRECTORY ${MACOSX_SPARKLE_DIR}/Sparkle.framework DESTINATION ${FRAMEWORK_DEST_DIR} USE_SOURCE_PERMISSIONS) endif() +# Set basic compiler warning/error flags for all targets +get_property(Launcher_TARGETS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS) +foreach(target ${Launcher_TARGETS}) + message(STATUS "Enabling all warnings as errors for target '${target}'") + if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + target_compile_options(${target} PRIVATE /W4 /WX /permissive-) + else() + target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic -Werror) + endif() +endforeach() + +# Disable some warnings in main launcher target due to being present in a lot of places. TODO: Fix them. +if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + target_compile_options(Launcher_logic PRIVATE /wd4100) # C4100 - unused parameter + target_compile_options(${Launcher_Name} PRIVATE /wd4100) # C4100 - unused parameter +else() + target_compile_options(Launcher_logic PRIVATE -Wno-unused-parameter -Wno-missing-field-initializers) + target_compile_options(${Launcher_Name} PRIVATE -Wno-unused-parameter -Wno-missing-field-initializers) +endif() + #### The bundle mess! #### # Bundle utilities are used to complete packages for different platforms - they add all the libraries that would otherwise be missing on the target system. # NOTE: it seems that this absolutely has to be here, and nowhere else.