-
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
Changes from all commits
12f21ad
57b012e
6b0be51
f5e6f35
987553e
8b2c890
04b0b77
5ca7c49
cc79f50
b418b42
38a805c
1b6b16a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The compiler warning was correct; this emit has no effect. batchWiz = new batchIgramWizard(m_igramsToProcess, this,Qt::Window);
connect(batchWiz,SIGNAL(swapBathConnections(bool)),this, SLOT(batchConnections(bool)));
batchConnections(true); |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It avoids unnecessary object copies because of detaching temporary.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 Let me explain FFMPEG changes in a different comment |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -475,8 +475,8 @@ void MainWindow::on_actionLoad_Interferogram_triggered() | |
| ui->useAnnulust->hide(); | ||
| if (dialog.exec()){ | ||
| if (dialog.selectedFiles().size() == 1){ | ||
| loadFile(dialog.selectedFiles().first()); | ||
|
|
||
| QStringList selectedFiles = dialog.selectedFiles(); | ||
| loadFile(selectedFiles.first()); | ||
| } | ||
| else{ | ||
| m_igramsToProcess = dialog.selectedFiles(); | ||
|
|
@@ -1764,8 +1764,9 @@ void MainWindow::on_actionCreate_Movie_of_wavefronts_triggered() | |
| if (QMessageBox::Yes == QMessageBox::question(0,"---------- 3D wave front Video maker -------------","Do you have FFMpeg and want it to make a video from these images?")) | ||
|
|
||
| { | ||
| QString cmd = QString("ffmpeg -framerate 1 -i %1%03d.jpg -c:v libx264 -vf format=yuv420p -y -r 25 %2").arg(dowavefront? waveprefix:astigprefix). \ | ||
| arg(dowavefront? "waveFronts.mp4": "astig.mp4"); | ||
| QString cmd = QString("ffmpeg -framerate 1 -i %1%03d.jpg -c:v libx264 -vf format=yuv420p -y -r 25 %2") | ||
| .arg(dowavefront ? waveprefix : astigprefix, | ||
| dowavefront ? "waveFronts.mp4" : "astig.mp4"); | ||
|
|
||
| bool ok = false; | ||
| QString text = QInputDialog::getText(this, | ||
|
|
@@ -1777,11 +1778,11 @@ void MainWindow::on_actionCreate_Movie_of_wavefronts_triggered() | |
| QDialog *dialog = new QDialog; | ||
| dialog->setWindowTitle("ffmpeg output"); | ||
| dialog->resize(1000,1000); | ||
| QTextEdit *textEdit = new QTextEdit(); | ||
| QTextEdit *textEdit = new QTextEdit(dialog); | ||
|
|
||
| QPushButton *closeButton = new QPushButton("Close"); | ||
| QPushButton *closeButton = new QPushButton("Close", dialog); | ||
|
|
||
| QVBoxLayout *layout = new QVBoxLayout; | ||
| QVBoxLayout *layout = new QVBoxLayout(dialog); | ||
| layout->addWidget(textEdit); | ||
| layout->addWidget(closeButton); | ||
|
|
||
|
|
@@ -1795,32 +1796,43 @@ void MainWindow::on_actionCreate_Movie_of_wavefronts_triggered() | |
| qDebug() << "plain text"<< text; | ||
| QApplication::setOverrideCursor(Qt::WaitCursor); | ||
| QProcess *proc = new QProcess; | ||
| QObject::connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), proc, SLOT(deleteLater())); | ||
| connect(proc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), | ||
| [=](int exitCode, QProcess::ExitStatus exitStatus){ qDebug() << "what" << exitStatus << "code" << exitCode; }); | ||
|
|
||
| // 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"; | ||
| } | ||
| }); | ||
|
|
||
|
Comment on lines
+1803
to
+1811
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this connects a dialog close (X) to |
||
| proc->setProcessChannelMode(QProcess::MergedChannels); | ||
| proc->setWorkingDirectory(dir); | ||
| QStringList args = text.split(" "); | ||
| QStringList args = QProcess::splitCommand(text); | ||
| qDebug() << "args" << args.mid(1); | ||
| proc->start("ffmpeg",args.mid(1)); | ||
|
|
||
|
|
||
| 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(); | ||
|
Comment on lines
-1808
to
+1827
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Then I created a |
||
|
|
||
| qDebug() << "done" ; | ||
|
|
||
|
|
||
| proc->waitForFinished(); | ||
| QString out = proc->readAll() ; | ||
| QApplication::restoreOverrideCursor(); | ||
|
|
||
| QString fn = dir + "/" + args[args.length()-1]; | ||
| QString fn = dir + "/" + args.last(); | ||
| QDesktopServices::openUrl(fn); | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
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.