Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a few warnings #1870

Merged
merged 8 commits into from
Jul 28, 2024
Merged

Fixed a few warnings #1870

merged 8 commits into from
Jul 28, 2024

Conversation

HeCorr
Copy link
Contributor

@HeCorr HeCorr commented Jul 26, 2024

This PR fixes a handful of simple warnings, mostly missing emit keywords and unused QStrings.

There were a lot more warnings but unfortunately my Qt and C++ knowledge isn't good enough to handle those so I decided not to risk breaking something. At least I fixed more than just the missing emits.

@@ -275,7 +272,7 @@ const PredefinedKeySetParams ImportImageSeqDialog::predefinedKeySetParams() cons
dot = finalList[0].lastIndexOf(".");

QStringList absolutePaths;
for (QString fileName : finalList) {
for (const QString &fileName : finalList) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (const QString &fileName : finalList) {
for (const QString &fileName : qAsCost(finalList)) {

By adding const here, you'll probably get an additional warning for 'Might detach container', as sch we use qAsConst(...) to make the list const also.

Copy link
Contributor Author

@HeCorr HeCorr Jul 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a separate warning with many occurrences but not all of them went away by adding qAsCost() and it felt like it just made the code less readable in many places, so I just skipped it entirely. thanks for the info.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, the CI doesn't like that.
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I recalled that we used it elsewhere in the code but it doesn't seem so.. it's likely because of backward compatibility then.
Alright ignore those comments 😅

@@ -562,7 +562,7 @@ int FileManager::countExistingBackups(const QString& fileName) const
const QString& baseName = fileInfo.completeBaseName();

int backupCount = 0;
for (QFileInfo dirFileInfo : directory.entryInfoList(QDir::Filter::Files)) {
for (const QFileInfo &dirFileInfo : directory.entryInfoList(QDir::Filter::Files)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (const QFileInfo &dirFileInfo : directory.entryInfoList(QDir::Filter::Files)) {
for (const QFileInfo& dirFileInfo : qAsConst(directory.entryInfoList(QDir::Filter::Files))) { {

By adding const here, you'll get an additional warning saying 'Might detach container', as such we use qAsConst(...).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding it like that fails:
image

adding it just around directory doesn't make the warning go away:
image

Copy link
Member

@MrStevns MrStevns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always nice to get rid of warnings, thanks for taking the initiative to fix them.
I will merge the PR now.

@MrStevns MrStevns merged commit 62a3a02 into pencil2d:master Jul 28, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants