Enable warnings as errors (#5101)

This commit is contained in:
Seth Flynn 2026-03-06 07:42:39 +00:00 committed by GitHub
commit 352b98db8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 112 additions and 272 deletions

View file

@ -35,16 +35,12 @@ add_compile_definitions($<$<NOT:$<CONFIG:Debug>>: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)

View file

@ -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
$<$<COMPILE_LANGUAGE:CXX>:${PROJECT_WARNINGS_CXX}>
# C warnings
$<$<COMPILE_LANGUAGE:C>:${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 "^<CMAKE_CXX_COMPILER>")
_set_project_warnings_add_target_link_option(
${_project_name} "$<$<COMPILE_LANGUAGE:CXX>:${PROJECT_WARNINGS_CXX}>"
)
endif()
if(CMAKE_C_LINK_EXECUTABLE MATCHES "^<CMAKE_C_COMPILER>")
_set_project_warnings_add_target_link_option(
${_project_name} "$<$<COMPILE_LANGUAGE:C>:${PROJECT_WARNINGS_C}>"
)
endif()
endfunction()

View file

@ -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), ".."));
}

View file

@ -1319,8 +1319,6 @@ if(WIN32)
set(LAUNCHER_RCS ${CMAKE_CURRENT_BINARY_DIR}/../${Launcher_Branding_WindowsRC})
endif()
include(CompilerWarnings)
######## Precompiled Headers ###########
if(${Launcher_USE_PCH})
@ -1336,10 +1334,6 @@ 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}")
target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(Launcher_logic PUBLIC LAUNCHER_APPLICATION)
@ -1424,8 +1418,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})
@ -1514,10 +1506,6 @@ 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}")
target_include_directories(filelink_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
@ -1577,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.

View file

@ -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;
}
@ -950,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");
@ -958,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, "\"", "\\\"");

View file

@ -172,7 +172,8 @@ int inf(QFile* source, std::function<bool(const QByteArray&)> 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);

View file

@ -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<std::size_t>(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<std::unique_ptr<BaseInstance>>& t)
{
beginInsertRows(QModelIndex(), m_instances.size(), m_instances.size() + t.size() - 1);
beginInsertRows(QModelIndex(), count(), static_cast<int>(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;

View file

@ -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(); }
int count() const { return static_cast<int>(m_instances.size()); }
InstListError loadList();
void saveNow();

View file

@ -303,7 +303,7 @@ QStringList toStringList(const QString& jsonString)
return {};
try {
return requireIsArrayOf<QString>(doc);
} catch (Json::JsonException& e) {
} catch (Json::JsonException&) {
return {};
}
}

View file

@ -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) {

View file

@ -49,7 +49,7 @@ bool JavaInstall::operator<(BaseVersion& a) const
{
try {
return operator<(dynamic_cast<JavaInstall&>(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<JavaInstall&>(a));
} catch (const std::bad_cast& e) {
} catch (const std::bad_cast&) {
return BaseVersion::operator>(a);
}
}

View file

@ -111,7 +111,7 @@ bool Metadata::operator<(BaseVersion& a) const
{
try {
return operator<(dynamic_cast<Metadata&>(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<Metadata&>(a));
} catch (const std::bad_cast& e) {
} catch (const std::bad_cast&) {
return BaseVersion::operator>(a);
}
}

View file

@ -223,7 +223,7 @@ void ComponentUpdateTask::loadComponents()
componentIndex++;
}
d->remoteTasksInProgress = taskIndex;
m_progressTotal = taskIndex;
m_progressTotal = static_cast<int>(taskIndex);
switch (result) {
case LoadResult::LoadedLocal: {
// Everything got loaded. Advance to dependency resolution.

View file

@ -21,7 +21,7 @@ class ComponentUpdateTask : public Task {
bool abort() override;
protected:
void executeTask();
void executeTask() override;
private:
void loadComponents();

View file

@ -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;

View file

@ -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);
}

View file

@ -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

View file

@ -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);

View file

@ -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()) {

View file

@ -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<MMCZip::ExportToZipTask>(m_options.output, m_gameRoot, files, "overrides/", true);
auto zipTask = makeShared<MMCZip::ExportToZipTask>(m_options.output, m_gameRoot, m_files, "overrides/", true);
zipTask->addExtraFile("manifest.json", generateIndex());
zipTask->addExtraFile("modlist.html", generateHTML());

View file

@ -72,7 +72,7 @@ class FlamePackExportTask : public Task {
FlameAPI api;
QFileInfoList files;
QFileInfoList m_files;
QMap<QString, HashInfo> pendingHashes{};
QMap<QString, ResolvedFile> resolvedFiles{};
Task::Ptr task;

View file

@ -150,11 +150,8 @@ 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()) {
for (auto flag : ModPlatform::modLoaderTypesToList(*loader)) {
loader_filter = ModPlatform::getModLoaderAsString(flag);
break;
}
if (loader.has_value() && loader != 0) {
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:

View file

@ -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<int>(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<int>(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<int>(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<int>(planeIndices.size() * sizeof(GLushort)));
b->m_indecesCount = planeIndices.size();
return b;

View file

@ -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 =

View file

@ -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);
}
}

View file

@ -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

View file

@ -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"));

View file

@ -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();
}

View file

@ -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;

View file

@ -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;

View file

@ -255,15 +255,12 @@ 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:
return ValidationStatus::Bad;
}
if (button == QMessageBox::No) {
return ValidationStatus::Bad;
}
}
return ValidationStatus::JavaBad;
} break;

View file

@ -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;

@ -1 +1 @@
Subproject commit 531449ba1c930c98e0bcf5d332b237a8566f9d78
Subproject commit 3538933614059f0f44388a2b16f3db25ce42285b