Skip to content

Conversation

@atsju
Copy link
Collaborator

@atsju atsju commented Jul 21, 2025

With these changes there are few enough warnings to re-enable Clazy problem matcher and display warnings in the pull request. close #210

I have found several real problems with this tool so I think it's worse it to fix the warnings.

AI is also of great help to make code changes. I'm not fluent enough in C++ to write high quality code but it helps me learn and I can check all proposals made by AI.

I keep the PR draft for now as I need to test my changes. Mainly about ffmpeg video generation.

@atsju atsju marked this pull request as draft July 21, 2025 06:28
@atsju atsju marked this pull request as ready for review July 21, 2025 16:16
@atsju
Copy link
Collaborator Author

atsju commented Jul 21, 2025

ffmpeg works fine. Still lots of memory leaks and probably problems in case of abort but this is for different PR

@atsju atsju requested review from githubdoe and gr5 July 21, 2025 16:17
@gr5
Copy link
Collaborator

gr5 commented Jul 22, 2025

Well it builds just fine in qtcreator and very basic testing works. I'll look at the code changes more carefully and possibly test features related to the code changes.

@githubdoe
Copy link
Owner

Does the Best fit conic update correctly? From the code I looked at I think it would be broken.

@gr5
Copy link
Collaborator

gr5 commented Jul 23, 2025

Does the Best fit conic update correctly? From the code I looked at I think it would be broken.

It works for me. Is there something in particular I should try? I just processed a single igram and the best fit conic value displayed is correct.

@gr5
Copy link
Collaborator

gr5 commented Jul 23, 2025

DFTArea.cpp line 143 is getting a warning message that the emit "probably has no effect". However it works fine because a few lines of code above, is "tools->connectTo(this) which connects dfttools slot to this signal.

Is there a way to disable this warning for this line of code only?
(I tried to make this an inline comment but the review process wouldn't let me as there was no code change here)

Copy link
Collaborator

@gr5 gr5 left a comment

Choose a reason for hiding this comment

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

I looked through these pretty carefully and I'm quite confident you didn't introduce any bugs. Except for the mmpeg stuff. That I didn't go through quite as carefully.

int closeNdx = -1;
int ndx = 0;
for (auto sample : m_list) {
for (const auto& sample : m_list) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you fix one warning only to create a different one? I don't really understand the warning.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

correct. I fixed an actual warning where the container was detaching.
And now we have a warning about C++11 not perfectly managing it. But this will be fixed with future compiler if I remember well. So I consider this warning less harmful and more future ready than previous one.

@atsju
Copy link
Collaborator Author

atsju commented Jul 23, 2025

Hi @gr5 and @githubdoe thank you for the careful review and testing. I really appreciate it.

DFTArea.cpp line 143 is getting a warning message that the emit "probably has no effect". However it works fine because a few lines of code above, is "tools->connectTo(this) which connects dfttools slot to this signal.

Is there a way to disable this warning for this line of code only? (I tried to make this an inline comment but the review process wouldn't let me as there was no code change here)

I had same conclusion as you and already though about it.
Yes I think it's possible to mask single warnings. However here I think we could just convert the slot to a function and it would be clean and maintainable. There is no hard reason to use the slot mechanism here. I did not fix it here to not introduce too much changes.

About mmpeg stuf, I actually tested (and discovered) it. It works at least as good as before with maybe a bit more error checking where you can cancel without hanging.

Unless you have more remarks I think with should merge this, the other two (or not if someone is against the changes) and then make a changelog and release 7.4.0 (new autoinvert feature ?) or 7.3.5

@gr5
Copy link
Collaborator

gr5 commented Jul 23, 2025

I think you should merge this.

I decided not to add any autoinvert features at this time. There didn't seem to be a strong interest. Yordan asked for the feature but didn't comment on my suggestions.

I do still plan to change the wording of the current popup dialog. Slightly. I just want to add a little more explanation about what it is doing and why.

Sure we can do a 7.3.5 release. The one "histogram related" bug is probably worth releasing just for that alone. Do you want me to write up the changes in revisionhistory?

@githubdoe
Copy link
Owner

githubdoe commented Jul 24, 2025

Nobody has addressed my comments.

@githubdoe
Copy link
Owner

I liked most of your invert modifications. I have recently been comparing wave fronts using the subtract. I not sure the code processes that correctly if it thinks the sign of the SA is not correct. I think in this case just like in the do not use the null case it should not invert. But I think it is silently inverting the result when it things all wave front signs should match the desired conic sign.

I just looked at the code and as near as I can tell it does nothing special after the subtract. Meaning that it is going to invert the wave front quietly if it has been told to for regular processing. Please someone see what they think about this.

I was looking forward to seeing your invert dialog pop up where I could then know if it was going to try and invert. Mine of course will not pop up if already told to invert which it has been in my current session.

@atsju
Copy link
Collaborator Author

atsju commented Jul 24, 2025

hi @githubdoe sorry if your comment has been addressed but this pull request does not change tool behavior at all so I'm not sure what your are talking about. Could you point out a commit, issue, pull request or a file+line ?

Is it about this pull request comment #208 (comment) ?
Or about this issue #199 ?
Best to answer at right place directly. I get notification of all your messages and I think so does @gr5 .
@gr5 maybe you understand Dale's comment better. I'm more focused on the code but do not understand all the invert and SA features.

Yes we must probably do a patch release soon mainly because of the fixed crash. I should be able to changelog within 48h. What about the 2 other PR ?
then we can do an other release if auto-invert needs changes.

I merge now. @githubdoe you can still answer here or anywhere. We will get notified.

@atsju atsju merged commit 86d5a39 into githubdoe:master Jul 24, 2025
8 checks passed
@atsju
Copy link
Collaborator Author

atsju commented Jul 24, 2025

@githubdoe also you can totally comment in closed pull requests. We will see it. Button is only "grayed out" as long as you type nothing.

@atsju atsju deleted the JST/clazyOnly branch July 24, 2025 16:50
Copy link
Owner

Choose a reason for hiding this comment

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

What I remember is that this emit is important to make the GUI work correctly. During Batch processing the signals need to be process differently. This enables that. So it should not be changed. Why is it removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The compiler warning was correct; this emit has no effect.
Indeed., the connect was done after emit. But you you call correct function after so it's working as intended. That makes me think the connect and signal can be removed completely as unused. Thank you for heads up.

    batchWiz = new batchIgramWizard(m_igramsToProcess, this,Qt::Window);
    connect(batchWiz,SIGNAL(swapBathConnections(bool)),this, SLOT(batchConnections(bool)));
    batchConnections(true);

Copy link
Owner

Choose a reason for hiding this comment

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

Put some debug in the signal processor for that emit and see if it does get processed to confirm that assertion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did not change the code here so I did not introduce new problems. Only warnings that were not processed before.

You are right it needs to be checked and I will do it some day.

Copy link
Owner

Choose a reason for hiding this comment

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

Just another way of coding what was already done. This is not necessary. It does not improve readability in my opinion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It avoids unnecessary object copies because of detaching temporary.
This whole pull request is about fixing warning you never saw before (from clazy tool). I did not do it for readability.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My understanding could be wrong but he creates axesH and axesV and then they are destroyed (deleted) at the end of the function. The older code also calls axes() which returns an object but it never gets deleted. maybe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense. I checked the internet and it does not cause memory leak. Temporary get freed correctly. It's just you copy the temporary thus double the object.
Inefficient but not dangerous.

Copy link
Owner

Choose a reason for hiding this comment

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

Explain why you think an additional variable (selectedFiles) was needed.

Explain what the modifications to the code that watches the FFMPEG output does. The previous code does occasionally hang and so I know it's not exactly correct. Forgive me if you have explained the changes somewhere that I have not seen.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

dialog.selectedFiles().first() will detach temporary
(https://github.com/KDE/clazy/blob/master/docs/checks/README-detaching-temporary.md)

Now that I read it again and again, I think the new code does exactly that but explicitly. So there is no warning but it's not really performance improved.

I should probably have changed to loadFile(dialog.selectedFiles().constFirst()); if it works it's better. I will change in a different PR if it works

Let me explain FFMPEG changes in a different comment

Copy link
Owner

Choose a reason for hiding this comment

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

Explain why changing the name was necessary. I don't think it was.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

because selected was clashing with a QWT function we inherited in this class. Nasty warning that could mask important issue. It probably did work fine but now we are 100% sure.

Copy link
Owner

Choose a reason for hiding this comment

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

Explain why an additional variable (files) was needed. I don't think one is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

in fact here it's somewhat different. you see files was already created at line 70. I just reused it

Copy link
Owner

Choose a reason for hiding this comment

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

While technically correct a char and an uchar have the same size I think. Thus each is equivalent in this context.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes they are 100% equivalent. But one is not overflowing and avoids warning. Thus I used CV's expected signness

@atsju
Copy link
Collaborator Author

atsju commented Jul 24, 2025

@githubdoe Comments successfully shared. I will answer them

Comment on lines +1803 to +1811
// ensure we kill ffmpeg if the dialog is closed
connect(dialog, &QDialog::finished, dialog, [=](int) {
if (proc->state() == QProcess::Running) {
proc->kill();
proc->waitForFinished();
qDebug() << "ffmpeg Process killed by user";
}
});

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this connects a dialog close (X) to QProcess proc. In some cases I have hang whole application by closing dialog at wrong time. Closing was not handled

Comment on lines -1808 to +1827
while (!proc->waitForFinished(200)){
QString q = proc->readAll();
if (q != "")
textEdit->append(q);
QApplication::processEvents();
}
connect(proc, &QProcess::readyRead, textEdit, [proc, textEdit]() {
QString output = proc->readAll();
if (!output.isEmpty())
textEdit->append(output);
});

QEventLoop loop;
QObject::connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit()));
loop.exec();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

other changes are more self explanatory so I will focus on this one. Let me know if you have more questions on the other changes and I will answer happily.

Original code was doing proc->readAll(); in a busy loop. Instead I connected QProcess::readyRead to what the loop was doing.

Then I created a QEventLoop loop who does the waiting instead of original waitForFinished. All the close and finish signals are connected correctly to kill everything properly.

@githubdoe
Copy link
Owner

Thank you. You might have guessed I never really understood how to capture output from a process. I always found that they could hang. I will study your example and try to fix similar issues in some of my personal apps I use.

@atsju
Copy link
Collaborator Author

atsju commented Jul 24, 2025

Thank you. You might have guessed I never really understood how to capture output from a process. I always found that they could hang. I will study your example and try to fix similar issues in some of my personal apps I use.

Also this code has been proposed and reviewed by chatGPT. Of course I studied it to understand and check it was what I expected. but I find it an excellent learning tool. It has been fed with documentation and "best" examples so it will often output best ways of doing things. I'm absolutely not the QT or C++ expert your think. I just like learning

atsju added a commit to atsju/DFTFringe that referenced this pull request Jul 24, 2025
atsju added a commit that referenced this pull request Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Clazy warning matcher

3 participants