Fix compiler warnings

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2026-02-25 15:37:20 +05:00
parent 94da1308ac
commit ec4b36b299
No known key found for this signature in database
GPG key ID: B77C34313AEE1FFF
25 changed files with 62 additions and 70 deletions

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

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

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(); }
qsizetype count() const { return static_cast<qsizetype>(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

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

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

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

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

@ -261,9 +261,6 @@ JavaWizardWidget::ValidationStatus JavaWizardWidget::validate()
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;