Clean up warnings

This commit is contained in:
GriffinR 2024-09-11 00:38:27 -04:00
parent 11bd41d000
commit 3178f20804
8 changed files with 19 additions and 33 deletions

View file

@ -49,10 +49,10 @@ void ParseUtil::recordErrors(const QStringList &errors) {
}
void ParseUtil::logRecordedErrors() {
QStringList errors = this->errorMap.value(this->curDefine);
const QStringList errors = this->errorMap.value(this->curDefine);
if (errors.isEmpty()) return;
QString message = QString("Failed to parse '%1':").arg(this->curDefine);
for (const auto error : errors)
for (const auto &error : errors)
message.append(QString("\n%1").arg(error));
logError(message);
}

View file

@ -33,7 +33,6 @@ static const int max_depth = 200;
using std::map;
using std::make_shared;
using std::initializer_list;
using std::move;
/* Helper for representing null - just a do-nothing struct, plus comparison
* operators so the helpers in JsonValue work. We can't use nullptr_t because
@ -164,7 +163,7 @@ protected:
// Constructors
explicit Value(const T &value) : m_value(value) {}
explicit Value(T &&value) : m_value(move(value)) {}
explicit Value(T &&value) : m_value(std::move(value)) {}
// Get type tag
Json::Type type() const override {
@ -211,7 +210,7 @@ class JsonString final : public Value<Json::STRING, QString> {
const QString &string_value() const override { return m_value; }
public:
explicit JsonString(const QString &value) : Value(value) {}
explicit JsonString(QString &&value) : Value(move(value)) {}
explicit JsonString(QString &&value) : Value(std::move(value)) {}
};
class JsonArray final : public Value<Json::ARRAY, Json::array> {
@ -219,7 +218,7 @@ class JsonArray final : public Value<Json::ARRAY, Json::array> {
const Json & operator[](int i) const override;
public:
explicit JsonArray(const Json::array &value) : Value(value) {}
explicit JsonArray(Json::array &&value) : Value(move(value)) {}
explicit JsonArray(Json::array &&value) : Value(std::move(value)) {}
};
class JsonObject final : public Value<Json::OBJECT, Json::object> {
@ -227,7 +226,7 @@ class JsonObject final : public Value<Json::OBJECT, Json::object> {
const Json & operator[](const QString &key) const override;
public:
explicit JsonObject(const Json::object &value) : Value(value) {}
explicit JsonObject(Json::object &&value) : Value(move(value)) {}
explicit JsonObject(Json::object &&value) : Value(std::move(value)) {}
};
class JsonNull final : public Value<Json::NUL, NullStruct> {
@ -269,12 +268,12 @@ Json::Json(double value) : m_ptr(make_shared<JsonDouble>(value)) {
Json::Json(int value) : m_ptr(make_shared<JsonInt>(value)) {}
Json::Json(bool value) : m_ptr(value ? statics().t : statics().f) {}
Json::Json(const QString &value) : m_ptr(make_shared<JsonString>(value)) {}
Json::Json(QString &&value) : m_ptr(make_shared<JsonString>(move(value))) {}
Json::Json(QString &&value) : m_ptr(make_shared<JsonString>(std::move(value))) {}
Json::Json(const char * value) : m_ptr(make_shared<JsonString>(value)) {}
Json::Json(const Json::array &values) : m_ptr(make_shared<JsonArray>(values)) {}
Json::Json(Json::array &&values) : m_ptr(make_shared<JsonArray>(move(values))) {}
Json::Json(Json::array &&values) : m_ptr(make_shared<JsonArray>(std::move(values))) {}
Json::Json(const Json::object &values) : m_ptr(make_shared<JsonObject>(values)) {}
Json::Json(Json::object &&values) : m_ptr(make_shared<JsonObject>(move(values))) {}
Json::Json(Json::object &&values) : m_ptr(make_shared<JsonObject>(std::move(values))) {}
/* * * * * * * * * * * * * * * * * * * *
* Accessors
@ -399,7 +398,7 @@ struct JsonParser final {
* Mark this parse as failed.
*/
Json fail(QString &&msg) {
return fail(move(msg), Json());
return fail(std::move(msg), Json());
}
template <typename T>

View file

@ -1963,9 +1963,9 @@ bool Project::readTilesetLabels() {
} else {
this->usingAsmTilesets = false;
const auto structs = parser.readCStructs(filename, "", Tileset::getHeaderMemberMap(this->usingAsmTilesets));
QStringList labels = structs.keys();
const QStringList labels = structs.keys();
// TODO: This is alphabetical, AdvanceMap import wants the vanilla order in tilesetLabelsOrdered
for (const auto tilesetLabel : labels){
for (const auto &tilesetLabel : labels){
appendTilesetLabel(tilesetLabel, structs[tilesetLabel].value("isSecondary"));
}
}
@ -2242,7 +2242,7 @@ bool Project::readHealLocations() {
// Pattern for an x, y number pair
const QString coordPattern = "\\s*(?<x>[0-9A-Fa-fx]+),\\s*(?<y>[0-9A-Fa-fx]+)";
for (const auto idName : constants) {
for (const auto &idName : constants) {
// Create regex pattern for e.g. "SPAWN_PALLET_TOWN - 1] = "
const QString initializerPattern = QString("%1\\s*-\\s*1\\s*\\]\\s*=\\s*").arg(idName);

View file

@ -12,11 +12,6 @@ static inline QSpacerItem *createSpacerH() {
return new QSpacerItem(2, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
}
static inline QSpacerItem *createSpacerV() {
return new QSpacerItem(1, 2, QSizePolicy::Minimum, QSizePolicy::Expanding);
}
void EventFrame::setup() {
// delete default layout due to lack of parent at initialization

View file

@ -81,7 +81,7 @@ QSize FlowLayout::sizeHint() const {
QSize FlowLayout::minimumSize() const {
QSize size;
for (const QLayoutItem *item : qAsConst(itemList))
for (const QLayoutItem *item : std::as_const(itemList))
size = size.expandedTo(item->minimumSize());
const QMargins margins = contentsMargins();
@ -97,7 +97,7 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const {
int y = effectiveRect.y();
int lineHeight = 0;
for (QLayoutItem *item : qAsConst(itemList)) {
for (QLayoutItem *item : std::as_const(itemList)) {
const QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
if (spaceX == -1)

View file

@ -234,10 +234,6 @@ void TilesetEditorMetatileSelector::drawUnused() {
int primaryLength = this->primaryTileset->metatiles.length();
int length_ = primaryLength + this->secondaryTileset->metatiles.length();
int height_ = length_ / this->numMetatilesWide;
if (length_ % this->numMetatilesWide != 0) {
height_++;
}
for (int i = 0; i < length_; i++) {
int tile = i;
@ -277,10 +273,6 @@ void TilesetEditorMetatileSelector::drawCounts() {
int primaryLength = this->primaryTileset->metatiles.length();
int length_ = primaryLength + this->secondaryTileset->metatiles.length();
int height_ = length_ / this->numMetatilesWide;
if (length_ % this->numMetatilesWide != 0) {
height_++;
}
for (int i = 0; i < length_; i++) {
int tile = i;

View file

@ -218,7 +218,7 @@ bool WildMonChart::usesGroupLabels() const {
QChart* WildMonChart::createSpeciesDistributionChart() {
QList<QBarSet*> barSets;
for (const auto species : getSpeciesNamesAlphabetical()) {
for (const auto &species : getSpeciesNamesAlphabetical()) {
// Add encounter chance data
auto set = new QBarSet(species);
for (auto groupName : this->groupNamesReversed)
@ -326,7 +326,7 @@ QChart* WildMonChart::createLevelDistributionChart() {
levelRange = getLevelRange(species, groupName);
} else {
// Species box is inactive, we display data for all species in the table.
for (const auto species : this->speciesInLegendOrder)
for (const auto &species : this->speciesInLegendOrder)
barSets.append(createLevelDistributionBarSet(species, groupName, false));
levelRange = this->groupedLevelRanges.value(groupName);
}

View file

@ -136,7 +136,7 @@ bool QGifImagePrivate::load(QIODevice *device)
int error;
GifFileType *gifFile = DGifOpen(device, readFromIODevice, &error);
if (!gifFile) {
qWarning(GifErrorString(error));
qWarning("%s", GifErrorString(error));
return false;
}
@ -228,7 +228,7 @@ bool QGifImagePrivate::save(QIODevice *device) const
int error;
GifFileType *gifFile = EGifOpen(device, writeToIODevice, &error);
if (!gifFile) {
qWarning(GifErrorString(error));
qWarning("%s", GifErrorString(error));
return false;
}