-
Notifications
You must be signed in to change notification settings - Fork 61
Some code improvements #211
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
Conversation
…I freeze in movie maker
|
ffmpeg works fine. Still lots of memory leaks and probably problems in case of abort but this is for different PR |
|
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. |
|
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. |
|
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? |
gr5
left a comment
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
Hi @gr5 and @githubdoe thank you for the careful review and testing. I really appreciate it.
I had same conclusion as you and already though about it. 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 |
|
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? |
|
Nobody has addressed my comments. |
|
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. |
|
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) ? 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 ? I merge now. @githubdoe you can still answer here or anywhere. We will get notified. |
|
@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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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);There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
@githubdoe Comments successfully shared. I will answer them |
| // 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"; | ||
| } | ||
| }); | ||
|
|
There was a problem hiding this comment.
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
| 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(); |
There was a problem hiding this comment.
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.
|
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 |
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.